jQuery UI Widgets Forums Grid jqxGrid with custom jqxCheckBox – show on selected rows

This topic contains 5 replies, has 2 voices, and was last updated by  Peter Stoev 11 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • andy8
    Participant

    Hello,

    I have been searching the docs for a while, but cannot find an answer to this simple question – how to show checkboxes on a grid only after the 3rd row. This is my code:

    columns = [{
    text: 'Core',
    datafield: 'key',
    columntype: 'custom',
    editable: true,
    width: 45,
    createeditor: function (row, value, editor) {
    if (row <= 2) {
    return false;
    } else {
    editor.jqxCheckBox({ checked: false, hasThreeStates:false});
    }
    },
    }.... other columns here....

    This code creates blank cells, which convert to checkboxes on click. On losing focus these cells show false or true. How can I get it fixed and show normal checkboxes upon grid initialization?

    Thanks


    Peter Stoev
    Keymaster

    Hi andy8,

    That cannot be done. The Checkbox column displays Checkboxes in all cells.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    andy8
    Participant

    Thanks, Peter. One more question – I have a very strange behavior of column checkboxes, when defined directly as

          columns = [{
    text: 'Core',
    datafield: 'key',
    columntype: 'checkbox',
    editable: true,
    width: 45
    }, {....

    When initialized, all boxes are unchecked, then when clicking on one of the boxes, all other boxes change their status to “undefined”. Then I can click each of these checkboxes manually and change their state. What causes all checkboxes to be undefined after the 1st click?

    Also, how can I change status of grid checkboxes programmatically, after the grid is initialized?

    Thanks!


    Peter Stoev
    Keymaster

    Hi andy8,

    – May be you missed to set the “type” during the datafields array initialization so your “checkbox” column is actually not bound to your data source.

    – to update the value of any cell, you can use the “setcellvalue” method of jqxGrid.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    andy8
    Participant

    Hi Peter,

    Thanks – it was because of the missing checkbox bounding.

    I still need to fix the issue with “removing” checkboxes from selected cells. I am playing with this code:

    function clearGrid(){
    for(var i=0; i<3; i++){
    $("#row"+i+"myGrid div:nth-child(3)").html("");
    //$("#row"+i+"myGrid div:nth-child(3)").children('div').hide(); //2nd option clears also borders - not good
    }
    }
    $("#myGrid").on('cellvaluechanged', function (event) {
    clearGrid();
    }

    Actually, it works with just a few problems. I am shooting that function clearGrid() also on ‘celldoubleclick’ and ‘cellbeginedit’. it works, but still these checkboxes appear again when I start editing other cells.

    My question: what jqxGrid events should I use to make sure that my function clearGrid() is triggered every time when it “redraws” checkboxes?

    Maybe you could suggest a more elegant solution how to suppress selected checkboxes.

    Thanks


    Peter Stoev
    Keymaster

    Hi andy8,

    Unfortunately, you cannot remove the Checkboxes from the Cells through the Grid’s API and I do not suggest you to try to do this, too. We cannot suggest you workaround for that. You can disable checkboxes, but you cannot remove them.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.