Grid Refreshing After Cancel on Edit Popup

Posted by jts-law on 01-May-2017 08:43

All,

I have a grid with a popup editor.  In the dataBound event, the Edit and Delete buttons may get hid based on the data values.  My issue is that if the user selects Cancel from the popup, the selected row is refreshed/redrawn and the Edit and Delete buttons that were hidden get displayed again.  I've tried applying my changes from the "cancel" event which doesn't work because the row refresh appears to happen after the cancel event.

Is there another event that runs after the grid or data source is refreshed that I can use?  If not, has anybody else run into this and found a solution?

Louis

Posted by egarcia on 01-May-2017 09:01

Hello Louis,

A possible way to do what you are looking for is to use a Row Template.

You can use specify a Row Template in a custom section file and refer to its ID or specify a RowTemplate function via the view factory file.

Please notice that if you want the buttons to display, you would have to explicitly list them in the Row Template code.

Here is an example of a RowTemplate function:

rowTemplate: function (dataItem) {

var template = kendo.template(

// '<tr style="background-color: lightblue" data-uid="#= uid #">' +

                   '<td>#= EmpNum #</td>' +

                   '<td><h4>#= LastName #</h4></td>' +

                   '<td>#= FirstName #</td>' +

                   '<td>#= Address #</td>' +

                   '<td>#= HomePhone #</td>' +

                   '<td>#= State #</td>' +

                   '<td>' + kendo.toString(dataItem.Birthdate, "MM-dd-yyyy") + '</td>' +

'<td><a class="k-button k-button-icontext k-grid-edit" href="##"><span class="k-icon k-i-edit"></span>Edit</a>' +

'<a class="k-button k-button-icontext k-grid-delete" href="##"><span class="k-icon k-i-delete"></span>Delete</a></td>' +

                   '</tr>'

);

return template(dataItem);

}

I hope this helps,

Edsel

All Replies

Posted by egarcia on 01-May-2017 09:01

Hello Louis,

A possible way to do what you are looking for is to use a Row Template.

You can use specify a Row Template in a custom section file and refer to its ID or specify a RowTemplate function via the view factory file.

Please notice that if you want the buttons to display, you would have to explicitly list them in the Row Template code.

Here is an example of a RowTemplate function:

rowTemplate: function (dataItem) {

var template = kendo.template(

// '<tr style="background-color: lightblue" data-uid="#= uid #">' +

                   '<td>#= EmpNum #</td>' +

                   '<td><h4>#= LastName #</h4></td>' +

                   '<td>#= FirstName #</td>' +

                   '<td>#= Address #</td>' +

                   '<td>#= HomePhone #</td>' +

                   '<td>#= State #</td>' +

                   '<td>' + kendo.toString(dataItem.Birthdate, "MM-dd-yyyy") + '</td>' +

'<td><a class="k-button k-button-icontext k-grid-edit" href="##"><span class="k-icon k-i-edit"></span>Edit</a>' +

'<a class="k-button k-button-icontext k-grid-delete" href="##"><span class="k-icon k-i-delete"></span>Delete</a></td>' +

                   '</tr>'

);

return template(dataItem);

}

I hope this helps,

Edsel

This thread is closed