Author Topic: Crash on empty space in filter click  (Read 4651 times)

jeff_b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Crash on empty space in filter click
« on: December 16, 2015, 11:18:04 pm »
Hello,

I currently have a problem throughout my grid where if the user clicks in certain spots (marked in red in image) in the filtering row we are receiving a crash:

Unhandled exception at line 3109, column 4 in pqgrid.dev.js     --- "JavaScript runtime error: dataIndx NA"



It is basically any where the filter is not occupying in the row with the filters.   Some columns may not need a filter and clicking these areas causes the issues.

Note: This is a simplified version of the code from the demo. 



Code: [Select]
<script>
        $(function () {
            var data = [[1, 'Exxon Mobil', '339,938.0', '36,130.0'],
            [2, 'Wal-Mart Stores', '315,654.0', '11,231.0']];

            var dataModel = {
                location: "local",
                sorting: "local",
                sortIndx: "OrderID",
                sortDir: "up"
            }

            var obj = {
                width: 840, height: 460,
                dataModel: dataModel,
                wrap: false,
                hwrap: false,
                showBottom: false,
                editable: false,
                selectionModel: { type: 'cell' },
                filterModel: { on: true, mode: "AND", header: true },
                title: "Shipping Orders",
                resizable: true,
                columnBorders: true,
                freezeCols: 2
            };

            obj.colModel = [
                { title: "Rank", width: 100, dataType: "integer" },
                { title: "Company", width: 200, dataType: "string",
                filter: { type: 'textbox', condition: 'contain', listeners: ['keyup'], dataIndx: 'Company' }
                },
                { title: "Revenues ($ millions)", width: 150, dataType: "float", align: "right" },
                { title: "Profits ($ millions)", width: 150, dataType: "float", align: "right" }
            ];
            obj.dataModel = { data: data };

            var $grid = $("#paged_grid").pqGrid(obj);

            $grid.pqGrid("filter", { oper: 'add', data: [] })
            .pqGrid("refresh");
        });
    </script>

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Crash on empty space in filter click
« Reply #1 on: December 17, 2015, 06:34:21 pm »
dataModel.sortIndx doesn't match any of the dataIndx in colModel.

jeff_b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Crash on empty space in filter click
« Reply #2 on: December 17, 2015, 07:04:14 pm »
Code: [Select]
<script>
        $(function () {
            var data = [[1, 'Exxon Mobil', '339,938.0', '36,130.0'],
            [2, 'Wal-Mart Stores', '315,654.0', '11,231.0']];

            var dataModel = {
                location: "local",
                sorting: "local",
                sortIndx: 'Company',
                sortDir: "up"
            }

            var obj = {
                width: 840, height: 460,
                dataModel: dataModel,
                wrap: false,
                hwrap: false,
                showBottom: false,
                editable: false,
                selectionModel: { type: 'cell' },
                filterModel: { on: true, mode: "AND", header: true },
                title: "Shipping Orders",
                resizable: true,
                columnBorders: true,
                freezeCols: 2
            };

            obj.colModel = [
                { title: "Rank", width: 100, dataType: "integer" },
                { title: "Company", width: 200, dataType: "string",
                filter: { type: 'textbox', condition: 'contain', listeners: ['keyup'], dataIndx: 'Company' }
                },
                { title: "Revenues ($ millions)", width: 150, dataType: "float", align: "right" },
                { title: "Profits ($ millions)", width: 150, dataType: "float", align: "right" }
            ];
            obj.dataModel = { data: data };

            var $grid = $("#paged_grid").pqGrid(obj);

            $grid.pqGrid("filter", { oper: 'add', data: [] })
            .pqGrid("refresh");
        });
    </script>


I changed the sortIndx to match the dataIndx but am still getting the error (that was caused by the switch from all my live data to dummy data)

I should mention that the filter DOES work correct for the company name but I get the crash when I click any where red.  (From original post)

Looks like the crash is in fn.getColIndx 

Call Stack    (all pqgrid.dev.js file)
 fn.getColIndx     (line 3109)
 fc.scrollColumn   (line 3562)
 handlFocus   (line 7399)


Is there a cdm for paramquery I can use for a jfiddle?

« Last Edit: December 17, 2015, 07:08:52 pm by jeff_b »

jeff_b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Crash on empty space in filter click
« Reply #3 on: December 17, 2015, 08:21:37 pm »
I tried looking at the demo from my second laptop (has never run this code)

went to paramquery.com/demos -> filter -> local header filtering

* I noticed all your text filters stretch across the entire column *

opened console and clicked the gray space under paid (not the check box the area next to the check box)
same error is logged into console. 
This is with IE 9 on that machine  IE 11 on my development machine


The same issue occurs in the remote filtering as well.
« Last Edit: December 17, 2015, 08:27:28 pm by jeff_b »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Crash on empty space in filter click
« Reply #4 on: December 17, 2015, 08:38:36 pm »
You are right, there is an error in IE when clicked in empty space beside filter input field.

I would look for a workaround or probably a fix in the next version.

jeff_b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Crash on empty space in filter click
« Reply #5 on: December 17, 2015, 08:47:09 pm »
Yikes!   

Any idea on time frame / suggestions on work around?


My initial thought would be to catch the click and disregard it somehow but this is my first web project so not exactly sure.


jeff_b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Crash on empty space in filter click
« Reply #6 on: January 05, 2016, 07:34:54 pm »
Just wondering: Any update on a fix or suggestions on a work around?