Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Leo F

Pages: [1] 2
1
Help for ParamQuery Pro / Issue in Firefox and float type column
« on: October 04, 2014, 08:24:27 am »
In columns of type float the backspace key does not work, but only in Firefox.

Here is one of your demos:
http://paramquery.com/pro/demos/editing_custom

Click to edit the freight column, and then try to use backspace.

Can this be resolved without changing column type or using a custom editor?

2
Help for ParamQuery Pro / Re: Import from Excel
« on: April 22, 2014, 04:36:47 am »
I don't know if it's appropriate to share code here, but I've created something for my use which does just that. The code below allows a user to paste a bunch of selected Excel cells into a ParamQuery grid. This is specific to my purposes, but it should be enough to get you going. This seems to work properly in IE8+, FF, Chrome. The relevant part starts at "$inp.on('paste', function (event) {", I provided the rest for context.


            obj.editor = {
                type: function (ui) {
                    var $cell = ui.$cell,
                    rowData = ui.rowData,
                    dataIndx = ui.dataIndx,
                    cls = ui.cls,
                    dc = $.trim(rowData[dataIndx]);
                    $cell.css('padding', '0');

                    var $inp = $('<input class="pq-grid-editor-default ' + cls + '" type="text" style="outline: none; width: 100%; height: 100%;" tabindx="0" value="' + dc + '"/>').appendTo($cell);
                    $inp.blur(function (event) {
                        grid.Container.pqGrid('saveEditCell');
                    });

                    $inp.on('paste', function (event) {
                        var data;
                        if (event.originalEvent && event.originalEvent.clipboardData && event.originalEvent.clipboardData.getData) {
                            data = event.originalEvent.clipboardData.getData('Text');
                        } else if (window.clipboardData && window.clipboardData.getData) {
                            data = window.clipboardData.getData('Text');
                        } else if (event.clipboardData && event.clipboardData.getData) {
                            data = event.clipboardData.getData('text/plain');
                        }

                        if (typeof data != "undefined") {
                            if (data.indexOf(String.fromCharCode(9)) == -1 && data.indexOf('\n') == -1)
                                return;

                            var cell = grid.Container.pqGrid("selection", { type: 'cell', method: 'getSelection' })[0];
                            var colIdx = grid.Container.pqGrid("getColIndx", { dataIndx: cell.dataIndx });
                            var rowIndx = cell.rowIndx;
                            var colModel = grid.Container.pqGrid("getColModel");
                            var pRows = data.split('\n');
                            for (i = 0; i < pRows.length; i++) {
                                pRows = pRows.split(String.fromCharCode(9));
                            }

                            for (i = 0; i < pRows.length; i++) {
                                if (grid.Container.pqGrid("hasClass", { rowIndx: rowIndx + i, cls: 'gridRowDivider' }) || grid.Container.pqGrid("hasClass", { rowIndx: rowIndx + i, cls: 'gridRowCalculated' }))
                                    continue;
                                var row = grid.Container.pqGrid("getRowData", { rowIndx: rowIndx + i });
                                if (typeof row == "undefined")
                                    break;
                                for (j = 0; j < pRows.length; j++) {
                                    var value = parseInt($.trim(pRows[j]));
                                    if (isNaN(value))
                                        value = null;
                                    var column = colModel[colIdx + j];
                                    if (typeof column == "undefined")
                                        break;
                                    if (pRows[j].length > 0) {
                                        SetValue(grid, column.dataIndx, row.rowId, value, true);
                                        if (j == 0 && i == 0)
                                            $(this).text(value);
                                    }
                                }
                            }
                            event.stopPropagation();
                            event.preventDefault();
                        }
                    });

                    $inp[0].select();
                },
                getData: function (ui) {
                    var $cell = ui.$cell;
                    var value = $(ui.$cell.children()[0]).val();
                    return value;
                }
            };

3
Help for ParamQuery Pro / Re: Error after upgrading to 2.0.4
« on: March 21, 2014, 11:43:59 pm »
The data is editable, and these validations are client side only.
I am already running the Validate() function from the cellSave event, but I also need to run it when the grid is initially loaded.
Anyway I have moved it to the load event, it seems to work now.

Thanks.

4
Help for ParamQuery Pro / Re: Error after upgrading to 2.0.4
« on: March 21, 2014, 09:23:36 pm »
I know I can adjust the JSON directly, but doesn't .pqGrid("addClass") do that?
Anyway this used to work fine in 2.0.3

What would be the correct event to use?

5
Help for ParamQuery Pro / Re: Error after upgrading to 2.0.4
« on: March 21, 2014, 05:58:15 pm »
I've narrowed down the issue a bit.

I am calling a function in beforeTableView:

obj.beforeTableView = function (event, ui) {
      Validate();
};

Among other things it adds/removes classes on some cells like so:
     grid.Container.pqGrid("addClass", { rowIndx: rowIndx, dataIndx: column.dataIndx, cls: 'gridCellValidationFailed' });

When all the cells are 0 or null, no validations are run so the part of the function where classes are added/removed is not reached and that's why the error does not happen. However if there is data then the error happens.
Also if I load a blank grid successfully, and then update the underlying data, followed by:
     grid.Container.pqGrid('refreshDataAndView');
then everything works fine.

6
Help for ParamQuery Pro / Re: Error after upgrading to 2.0.4
« on: March 21, 2014, 01:55:57 am »
What specifically would you like to see?

7
Help for ParamQuery Pro / Error after upgrading to 2.0.4
« on: March 20, 2014, 11:52:51 pm »
I am seeing this error for any grid that has cells with data in them, and the grid fails to load/display properly.

TypeError: $td is undefined pqgrid.dev.js:4225

Briefly looking at the source it would indeed seem that $td is not being set to anything.

8
Any idea on the timeline for that?

9
Help for ParamQuery Pro / multi select cells to delete values
« on: March 13, 2014, 08:56:36 am »
What would be a good approach to take to be able to select multiple cells and be able to call delete on them?
I know there is api already to allow selecting multiple cells, how can I check which ones are selected and do some kind of processing on them?

10
Is there a planned functionality update to allow copying pasting from excel into the grid?

11
Help for ParamQuery Pro / Re: changing cell css in colModel.render
« on: March 05, 2014, 10:19:41 am »
Put grid.Container.pqGrid("refreshCell", { rowIndx: ui.rowIndx, dataIndx: ui.dataIndx }); in a setTimeout? How would that help?

12
Help for ParamQuery Pro / changing cell css in colModel.render
« on: March 05, 2014, 02:12:22 am »
I have the following code. Basically I need to change the class of a cell based on the value.

col.render = function (ui) {
                            var noVal = false;
                            if (ui.cellData == null || ui.cellData == "")
                                noVal = true;

                            if (grid.Container.pqGrid("hasClass", { rowIndx: ui.rowIndx, cls: 'gridRowTieDiff' })) {
                                if (noVal || ui.cellData == "0") {
                                    grid.Container.pqGrid("removeClass", { rowIndx: ui.rowIndx, dataIndx: ui.dataIndx, cls: 'gridCellTieFailed' });
                                } else {
                                    grid.Container.pqGrid("addClass", { rowIndx: ui.rowIndx, dataIndx: ui.dataIndx, cls: 'gridCellTieFailed' });
                                }
                            }

                            if (noVal)
                                return null;

                            return "$" + parseInt(ui.cellData).toLocaleString();
                        };


This does not quite work because this event is apparently called after the grid refresh happens, and so the styles actually that get added/removed take effect on the next refresh.
Adding
grid.Container.pqGrid("refreshCell", { rowIndx: ui.rowIndx, dataIndx: ui.dataIndx });
creates infinite recursion.
Is there another way to do this?

13
Maybe I missed it in, but I see no way to do it within the api.

14
Ok so this works for most cases, but I have a situation where in some rows some cells are editable, but not others. Screenshot attached(white cells are not editable, yellow and dark blue rows are not editable). There is no direct property of the ui object when the editable check is called that has the column index, but there is the ui.rowData["pq_cellselect"] which gets the dataIndx of the currently selected column. Unfortunately this property appears to only be available when a cell is clicked, if a user uses keyboard navigation this property is undefined. So as a workaround I am storing the last known selected column, but of course this only works if the user uses the up/down keys to navigate. Using tab, enter, or right key prevent this from working properly.

            obj.editable = function (ui) {
                var rowIndx = ui.rowIndx;
                var colIndx = getNameOfFirstObjectProperty(ui.rowData["pq_cellselect"]);
                if (!colIndx)
                    colIndx = grid.LastSelectedDataIndx;
                else
                    grid.LastSelectedDataIndx = colIndx;
               
                if (!$(this).pqGrid("hasClass", { rowIndx: rowIndx, dataIndx: colIndx, cls: 'gridCellDisabled' }) && $(this).pqGrid("hasClass", { rowIndx: rowIndx, cls: 'gridRowEditable' }))
                    return true;
                else
                    return false;
            };

How can I resolve this?

15
Help for ParamQuery Pro / Re: toolbar button not being added properly?
« on: February 10, 2014, 01:08:33 am »
Yep. Changing the load order of jquery and bootstrap resolved the issue. Thanks.

Another question, is it possible to change the styles that are applied to the column headers?
The colModel has a cls property, but that only affects the data cells.

Pages: [1] 2