jQuery UI Widgets › Forums › Grid › loop in cellclass not working
This topic contains 3 replies, has 2 voices, and was last updated by admin 2 years, 2 months ago.
-
Author
-
hello if I use foreach inside the cellclass block it doesn’t work
var cellclass = function (row, column, value, rowData) { var id = $('#Product #SUPPLIER_OWNER_ID_hdn').val(); var disableRows = new Array(); if (ElementValuesCheck(id)) { disableRows = id.split(','); disableRows = jQuery.makeArray(disableRows); } $(disableRows).each(function (y, n) { if (rowData.OWNER_ID == parseInt(n)) { return "rowError" } }); }but it works if I don’t use foreach, what is the reason for this?
var cellclass = function (row, column, value, rowData) { var id = $('#Product #SUPPLIER_OWNER_ID_hdn').val(); var disableRows = new Array(); if (ElementValuesCheck(id)) { disableRows = id.split(','); disableRows = jQuery.makeArray(disableRows); } return "rowError" }Hi Serdar,
The reason is that this is “each” function so when you put “return” in it, you return the “each” function, not the cellclass function.
Best regards,
Peter StoevjQWidgets Team
https://www.jqwidgets.com/Well, as you can see in the example, I have a forbidden list. When loading data to the grid, if the data in the row is in the forbidden list, how can I make that row red? I cannot get it as (disable/enable) by putting a flag from the database because the forbidden list is created dynamically on the screen and no record is made to the db. Is there any other way to see if the data in the cell is in the forbidden list?
thank youHi Serdar,
I meant that you can use a native Javascript for loop, because by using a function from jquery such as .each, the return statement is in the context of that function, not in the context of the cellclass callback function.
Best regards,
Peter StoevjQWidgets Team
https://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.