jQWidgets Forums
jQuery UI Widgets › Forums › Grid › jqxGrid paging after addrow
This topic contains 2 replies, has 2 voices, and was last updated by andreopmaria 5 years, 9 months ago.
-
Author
-
Hi! I need some help with the following
After successful addrow when try paging“jqxdata.js?v=23_7_19_01′:8 Uncaught TypeError: Cannot read property ‘909’ of undefined”
Html
<div id='jqxWidget' style="width: 100%; height: 94%;"> <div id="jqxgrid"></div> </div>
JS
var type = "POST"; var datatype = "json"; var url = 'Admin/Handlers/Countries.ashx'; var datafields = [ { name: 'can_country_id', type: 'number', attributes: 'required'}, { name: 'name_gr', type: 'string', attributes: ''}, { name: 'name_en', type: 'string', attributes: '' }, { name: 'name_bg', type: 'string', attributes: '' }, { name: 'name_tr', type: 'string', attributes: '' }, { name: 'name_ro', type: 'string', attributes: '' }, { name: 'hasjobs', type: 'bool', attributes: '' } ]; $(document).ready(function () { var theme = 'bootstrap'; var getAdapter = function () { var source = { type: "POST", datatype: "json", datafields: datafields, id: 'can_country_id', url: url, root: 'Rows', sortcolumn: 'can_country_id', sortdirection: 'asc', beforeprocessing: function(data) { source.totalrecords = data.TotalRows; }, sort: function(event) { $("#jqxgrid").jqxGrid('updatebounddata', 'sort'); }, addrow: function (rowid, rowdata, position, commit) { $.each(rowdata, function (name, value) { $.each(datafields, function (key, val) { if (val.name == name) { datafields[key]['value'] = value; datafields[key]['type'] = val.type; datafields[key]['attributes'] = val.attributes; } }); }); $.ajax({ type: type, datatype: datatype, url: url + '?action=new&tbl=Career_Countries', contentType: "application/json; charset=utf-8", data: JSON.stringify(datafields), success: function (data) { if (!data) { commit(true); } else { console.log(data); commit(false); } } }); }, updaterow: function (rowid, rowdata, commit) { commit(true); }, }; var dataAdapter = new $.jqx.dataAdapter(source, {}); return dataAdapter; } // validation function var validateFunc = function (datafield, value) { switch (datafield) { case "can_country_id": if(Math.floor(value) != value && !$.isNumeric(value)) { return { message: "Entered quantity should be positive number", result: false }; } if (value == "") return { message: "Required field", result: false }; return true; break; } return true; }; $("#jqxgrid").jqxGrid( { width: '100%', autoheight: true, altrows: true, virtualmode: true, theme: theme, source: getAdapter(), editable: true, editmode: 'selectedrow', sortable: true, filterable: true, pageable: true, pagermode: 'simple', pagesize: 5, showeverpresentrow: true, everpresentrowposition: "top", everpresentrowactions: "add", everpresentrowactionsmode: "columns", selectionmode: 'checkbox', rendergridrows: function (obj) { return obj.data; }, columns: [ { text: 'ID', datafield: 'can_country_id', filtertype: 'input', width: '6%', columntype: 'textbox', validateEverPresentRowWidgetValue: validateFunc, validation: validateFunc }, { text: 'Name (GR)', datafield: 'name_gr', columntype: 'textbox', filtertype: 'input', width: '16.4%' }, { text: 'Name (EN)', datafield: 'name_en', columntype: 'textbox', filtertype: 'input', width: '16.4%' }, { text: 'Name (BG)', datafield: 'name_bg', columntype: 'textbox', filtertype: 'input', width: '16.4%' }, { text: 'Name (TR)', datafield: 'name_tr', columntype: 'textbox', filtertype: 'input', width: '16.4%' }, { text: 'Name (RO)', datafield: 'name_ro', columntype: 'textbox', filtertype: 'input', width: '16.4%' }, { text: 'Has jobs', datafield: 'hasjobs', columntype: 'checkbox', width: '5%', createEverPresentRowWidget: function (datafield, htmlElement, popup, addCallback) { var checkbox = $('<div style="position: absolute; top: 50%; left: 50%; margin-top: -9px; margin-left: -12px; overflow: visible; cursor: auto;" id="jqxcheckbox"</div>').appendTo(htmlElement); checkbox.jqxCheckBox(); return checkbox; }, getEverPresentRowWidgetValue: function (datafield, htmlElement, validate) { var value = htmlElement.val(); return value; }, }, { text: 'Actions', datafield: 'addButtonColumn', width: '5%', sortable: false }, ] }); });
Response:
{“TotalRows”:”16″,”Rows”:[{“rownumb”:6,”can_country_id”:43,”name_gr”:””,”name_en”:””,”name_bg”:””,”name_tr”:””,”name_ro”:””,”hasjobs”:0},{“rownumb”:7,”can_country_id”:45,”name_gr”:””,”name_en”:””,”name_bg”:””,”name_tr”:””,”name_ro”:””,”hasjobs”:0},{“rownumb”:8,”can_country_id”:54,”name_gr”:””,”name_en”:””,”name_bg”:””,”name_tr”:””,”name_ro”:””,”hasjobs”:0},{“rownumb”:9,”can_country_id”:55,”name_gr”:””,”name_en”:””,”name_bg”:””,”name_tr”:””,”name_ro”:””,”hasjobs”:0},{“rownumb”:10,”can_country_id”:57,”name_gr”:””,”name_en”:””,”name_bg”:””,”name_tr”:””,”name_ro”:””,”hasjobs”:1}]}Hi andreopmaria,
Could you share jsfiddle.net example which demonstrates the reported behavior?
Best Regards,
Peter StoevjQWidgets Team
https://www.jqwidgets.comOk it was my mistake, post data were
Object attributes: "" name: "name_ro" type: "string" value: "ww"
value conflict with line 1839 jqxdata.js
P[L.name] = P[L.value]
-
AuthorPosts
You must be logged in to reply to this topic.