Results 1 to 2 of 2

Thread: Want grid checkcolumn to display !value of dataIndex

  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    631
    Answers
    10

    Default Want grid checkcolumn to display !value of dataIndex

    My model has a field 'notnull' which is server data and my grid's column is a checkcolumn with text of 'Allow Null'. I'm trying to get the column to render !value and can't figure out how. I tried a renderer but it removes checkbox completely.

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    I use the following:

    Code:
    { header: 'Inactive', dataIndex: 'bInactive', 
                    editor: {
                        xtype: 'checkbox',
                        allowBlank: true,
                        cls: 'x-grid-checkheader-editor'
                    },
                    renderer: function(value) {    // This function converts true and false into checkbox checked or unchecked
                        if (value == "0" || value == "false")
                            value = false;
                        else if(value == "1" || value == "true")
                            value = true;
                        return "<input type='checkbox' disabled='disabled'" + (value ? "checked='checked'" : "") + ">";
                    }
                }
    This allows it to be used in row editing or cell editing plugins also. In my case, the value could be a string and thats why I do the if-else. At the end, depending on the value, you can tell the checkbox to be checked or not...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •