jQuery UI Widgets Forums Grid loop in cellclass not working

This topic contains 3 replies, has 2 voices, and was last updated by  admin 5 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • loop in cellclass not working #135112

    Serdar
    Participant

    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"
        }
    loop in cellclass not working #135115

    admin
    Keymaster

    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 Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

    loop in cellclass not working #135158

    Serdar
    Participant

    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 you

    loop in cellclass not working #135163

    admin
    Keymaster

    Hi 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 Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.