Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
625
IgGrid updating Binary value 0 or 1 only
posted

Hi,
I am using IgGrid

i am facing one issue, when i have to edit the column value either 0 or 1

i have to able type 0.5 ect. how to avoid typing dot(.)

using the below code

            name: "Updating",
            enableAddRow: false,
            enableDeleteRow: true,
            enableCheckBoxes: true,
            editMode: "row",
            autoCommit: true,
            columnSettings: [
             {
                 columnKey: "RXClub",                             
                 editorOptions: {type: 'number', minValue: 0, maxValue: 1}
             }

           ]

Thanks in advance

Robin Bronston D

Parents
No Data
Reply
  • 485
    Offline posted

    Hello Robin,

     

    Thank you for posting in our forum.

     

    There are some minor modifications that have to be made to the code you have provided and it would prevent the user from being able to use floating-point numbers:

    • enableDeleteRow: true – this could be removed as it is "true" by default, no need to declare it again explicitly
    • enableCheckboxes – there is a similar option to this one, called renderCheckboxes, but it has to be declared in the grid, not in the Updating feature. Also the dataType for the column has to be “bool” instead of “number” in order for it to work
    • autoCommit – again, this has to be declared for the whole grid, not in the Updating feature
    • editorOptions: {type: ‘number’…….} – if this gets replaced with editorOptions: {dataMode: "int",……} your sample would work – the editor for this column would accept only the integers 0 and 1

     

    Here are two possible grid configurations: the first one has a number column that accepts only 0 and 1, and shows them without any additional formatting; the other one uses a boolean column instead and renders checkboxes.

    I have provided the whole initialization configurations so you could see where the grid options have to be declared, and where the Updating ones should be:

     

    A number column without checkboxes:

    $("#grid").igGrid({
        dataSource: ds,
        responseDataKey: "results",
        primaryKey: "ProductID",
        autoCommit: true,
        columns: [   
            { headerText: "Product ID", key: "ProductID", dataType: "number", width: "25%"},
            { headerText: "Product Name", key: "ProductName", dataType: "string", width: "25%" },
            { headerText: "Category", key: "CategoryName", dataType: "string", width: "25%"},
            { headerText: "Available", key: "Available", dataType: "number", width: "25%" }
        ],
        features: [
            {
                name: "Updating",
                editMode: "row",
                columnSettings: [
                    {
                        columnKey: "Available",
                        editorOptions: {
                            dataMode: "int",
                            minValue: 0,
                            maxValue: 1
                        }
                    }
                ]
            }
        ]
    })

     

    A boolean column that shows checkboxes instead of zeroes and ones: 

    $("#grid").igGrid({
        dataSource: ds,
        responseDataKey: "results",
        primaryKey: "ProductID",
        renderCheckboxes: true,
        autoCommit: true,
        columns: [   
            { headerText: "Product ID", key: "ProductID", dataType: "number", width: "25%"},
            { headerText: "Product Name", key: "ProductName", dataType: "string", width: "25%" },
            { headerText: "Category", key: "CategoryName", dataType: "string", width: "25%"},
            { headerText: "Available", key: "Available", dataType: "bool", width: "25%" }
        ],
        features: [
            {
                name: "Updating",
                editMode: "row"
            }
        ]
    })

     

    If you need any additional assistance, feel free to contact me.

Children
No Data