jQWidgets Forums
jQuery UI Widgets › Forums › Grid › How to identify the custom class of cell
Tagged: #jqwidgets-grid, grid, javascript grid, jquery grid
This topic contains 2 replies, has 2 voices, and was last updated by Hristo 7 years, 10 months ago.
-
Author
-
In the below code, i am showing borders highlighted if there are any validation failure and that is working fine Is there any way to check if validation errors on Grid on clicking a button? Click the button at bottom and there i would like identify if there are any errors
I applied custom class for error borders.
If i can identify if class ‘erroredcolumn’ while iterating cells of grid, that would be greatHello Rana,
You could create an array that will collect all cells that are wrong.
When you press the button to check for this you will turn to this array
Please, take a look at the example below:var data = generatedata(500); var source = { localdata: data, datafields: [{ name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'date', type: 'date' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' }], datatype: "array" }; var adapter = new $.jqx.dataAdapter(source); var listIdInvalidCellFirstname = []; $("#jqxgrid").jqxGrid({ width: 500, theme: 'energyblue', source: adapter, sortable: true, editable: true, columns: [{ text: 'First Name', datafield: 'firstname', columngroup: 'Name', width: 90, cellclassname: function(row, columnfield, value) { if (value == undefined || value.length < 4 ) { if(listIdInvalidCellFirstname.indexOf(row) == -1) { listIdInvalidCellFirstname.push(row); } return 'erroredcolumn'; } } }, { text: 'Last Name', columngroup: 'Name', datafield: 'lastname', width: 90 }, { text: 'Product', datafield: 'productname', width: 170 }, { text: 'Order Date', datafield: 'date', width: 160, cellsformat: 'dd-MMMM-yyyy' }, { text: 'Quantity', datafield: 'quantity', width: 80, cellsalign: 'right' }, { text: 'Unit Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2' }], }); $("#jqxbutton").jqxButton({ theme: 'energyblue', height: 30 }); $('#jqxbutton').click(function () { console.log('Check wrong cells', listIdInvalidCellFirstname); });
I would like to suggest you try to use options of the
validation
callback as in this demo:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/cellediting.htm?lightBest Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.