javascript - jQuery Grid error on 2nd filter: Uncaught TypeError: Cannot read property 'value' of undefined -


i'm using jqwidgets v3.8.0 (2015-apr) version take json database , display it. however, when filter example role_id works fine. if filter same column 2nd time, error:

uncaught typeerror: cannot read property 'value' of undefined a.extend._addfilterwidget @ jqx-all.js:7 a.extend._updatefilterrow @ jqx-all.js:7 b.extend._rendercolumnheaders @ jqx-all.js:7 b.extend.rendergridcontent @ jqx-all.js:7 b.extend._render @ jqx-all.js:7 b.extend.databind.dataview.update @ jqx-all.js:7 b.jqx.dataview.databind.z @ jqx-all.js:7 b.jqx.dataview.databind.k @ jqx-all.js:7 i.jqx.dataadapter.calldownloadcomplete @ jqx-all.js:7 i.jqx.dataadapter.databind.xhr.i.jqx.data.ajax.success @ jqx-all.js:7 n.callbacks.j @ jquery-2.1.1.js:2 n.callbacks.k.firewith @ jquery-2.1.1.js:2 s @ jqx-all.js:7 i.jqx.data.ajaxtransport.send.h @ jqx-all.js:7 

or when switching separate files

uncaught typeerror: cannot read property 'value' of undefined a.extend._addfilterwidget @ jqxgrid.filter.js:584 a.extend._updatefilterrow @ jqxgrid.filter.js:558 b.extend._rendercolumnheaders @ jqxgrid.js:7 b.extend.rendergridcontent @ jqxgrid.js:7 b.extend._render @ jqxgrid.js:7 b.extend.databind.dataview.update @ jqxgrid.js:7 b.jqx.dataview.databind.z @ jqxgrid.js:7 b.jqx.dataview.databind.k @ jqxgrid.js:7 i.jqx.dataadapter.calldownloadcomplete @ jqxdata.js:7 i.jqx.dataadapter.databind.xhr.i.jqx.data.ajax.success @ jqxdata.js:7 n.callbacks.j @ jquery-2.1.1.js:2 n.callbacks.k.firewith @ jquery-2.1.1.js:2 s @ jqxdata.js:7 i.jqx.data.ajaxtransport.send.h @ jqxdata.js:7 

does have idea might cause this? here's function i'm using

function initjqgrid($grid, datafields, gridcols, url, editable) { var source = {     datatype: "json",     datafields: datafields,     url: url,     root: "data",     cache: false,     beforeprocessing: function (data) {         source.totalrecords = data.params.filtered;     },     formatdata: function (data) {         var newdata = {}, = 0, columndata;         var field = "", value = "", condition = "";          newdata["length"] = data.pagesize;         newdata["page"] = data.pagenum + 1;          if (data.filterscount > 0) {             (i = 0; < data.filterscount; i++) {                 field = data["filterdatafield" + i];                 value =  data["filtervalue" + i];                 columndata = $grid.jqxgrid('getcolumn', field);                  if (columndata.cellclassname == "satoshicell") value = parsefloat(value) * 100000000;                  switch (data["filtercondition" + i]) {                     case "equal":                         condition = "{val}";                         break;                     case "less_than":                         condition = "< {val}";                         break;                     case "greater_than":                         condition = "> {val}";                         break;                     case "less_than_or_equal":                         condition = "<= {val}";                         break;                     case "greater_than_or_equal":                         condition = ">= {val}";                         break;                     case "null":                         condition = "is null";                         break;                     case "not_null":                         condition = "is not null";                         break;                     case "contains_case_sensitive":                     case "contains":                         condition = "like \'%{val}%\'";                         break;                     case "does_not_contain_case_sensitive":                     case "does_not_contain":                         condition = "not \'%{val}%\'";                         break;                     case "starts_with_case_sensitive":                     case "starts_with":                         condition = "like \'{val}%\'";                         break;                     case "ends_with_case_sensitive":                     case "ends_with":                         condition = "like \'%{val}\'";                         break;                     case "empty":                         condition = "like \'\'";                         break;                     case "not_empty":                         condition = "not \'\'";                         break;                 }                  if (newdata.hasownproperty(field)) {                     if (!$.isarray(newdata[field])) {                         newdata[field] = [newdata[field], condition.replace("{val}", value)];                     } else newdata[field].push(condition.replace("{val}", value));                 } else newdata[field] = condition.replace("{val}", value);                  if (!newdata.hasownproperty("mode")) newdata["mode"] = [];                  if (data.hasownproperty("filteroperator" + i)) {                     if (data["filteroperator" + i] == 0) {                         if ($.inarray("and " + field, newdata["mode"]) < 0) newdata["mode"].push("and " + field);                     }                     else if (data["filteroperator" + i] == 1) {                         if ($.inarray("or " + field, newdata["mode"]) < 0) newdata["mode"].push("or " + field);                     }                 }             }         }          if (data.hasownproperty("sortdatafield") && data.sortdatafield != "") {             newdata["order"] = data.sortdatafield + " " + data.sortorder.touppercase();         }          return newdata;     },     filter: function () {         // update grid , send request server.         $grid.jqxgrid("updatebounddata");     },     sort: function () {         // update grid , send request server.         $grid.jqxgrid("updatebounddata");     } };  if (typeof editable == "undefined" || editable == undefined) editable = false;  var dataadapter = new $.jqx.dataadapter(source);  var width = 0; $.each(gridcols, function (k, v) { width += v.width; }); if (width == 0) width = 1000;  // initialize jqxgrid $grid.jqxgrid({     theme: "theme",     //rowsheight: 35,     //width: width,     showfilterrow: true,     width: "100%",     source: dataadapter,     autoheight: true,     pageable: true,     virtualmode: true,     filterable: true,     sortable: true,     columnsresize: true,     editable: editable,     selectionmode: "multiplecellsadvanced",     pagesizeoptions: ["20", "50", "100", "500", "1000"],     pagesize: 20,     rendergridrows: function() { return dataadapter.records; },     columns: gridcols }); } 

and calling with:

initjqgrid($("#jqxgrid"), [         {name: "id", type: "number"},         {name: "email", type: "string"},         {name: "first_name", type: "string"},         {name: "last_name", type: "string"},         {name: "role_id", type: "number"},         {name: "created", type: "date"},     ], [         {             text: "id", datafield: "id", width: 50, pinned: true,             cellsrenderer: function (row, column, value, defaulthtml, columnproperties) {                 return '<a href="/admin/users/view/' + value + '/" target="_blank">' + value + "</a>";             }         },         {text: "email", datafield: "email", pinned: true, width: 250},         {text: "first name", datafield: "first_name", width: 100},         {text: "last name", datafield: "last_name", width: 100},         {text: "role", datafield: "role_id", filtertype: "checkedlist", width: 50},         {text: "registered", datafield: "created", editable: false, filtertype: "date", width: 100, cellsformat: "dd.mm.yyyy hh:mm:ss"},       ], "/admin/users.json", true ); 

i tried removing id field's cellsrenderer, , didn't make difference. tried googling around, still have no idea might causing this. seems data source's formatdata gets called fully, , error happens time after it.

after poking around , adding console logging _addfilterwidget, turns out on 2nd filter application role_id field, 2 other boolean fields filters, though nothing selected fields. same 2 fields have filtertype: "checkbox", columntype: "checkbox" in column definition, taken api documentation. turns out, filtertype: "checkbox" very wrong. has filtertype: "bool". why did have such pain, don't know.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -