Show buttons on iggrid based on conditions for each row

I show igGrid on my view, which have the right to edit and delete in each row.

I want to show buttons for editing and deleting based on entries. Based on the data in the column, there will be Edit and Delete buttons on some row, while others can only have an Edit or Delete button. I want to control these buttons when the grid is displayed, so the user does not see any button that is not applicable.

Please tell me how to achieve this function in igGrid and what event should I name?

+3
source share
1 answer

There are several ways to do this, but I think it’s easiest to use conditional patterns (either for a row or for a specific column). Using them, you can evaluate other column values ​​based on these render buttons. I started with a sample column template and added another column for editing:

$("#grid").igGrid({
    //...
    columns : [
        {
            headerText : "",
            key : "Delete",
            dataType : "string",
            width : "10%",
            unbound : true,
            template : "{{if ${MakeFlag} }}<input type='button' onclick='deleteRow(${ProductID})' value='Delete' class='delete-button'/>{{/if}}"
        }
        //...
    ]
});

jSFiddle: http://jsfiddle.net/damyanpetev/dVLrA/

You can use this template in the actual column that you are evaluating if its sole purpose is a flag to enable buttons. If you want more flexibility or use more than one sequential condition to put both buttons in the same column, you can use jsRender instead, as in this one: http://jsfiddle.net/damyanpetev/85ZGS/

: localSchemaTransform false, , .

:

+3

All Articles