This is a migrated thread and some comments may be shown as answers.

Cancel popup, clears grid background color

4 Answers 247 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 25 Oct 2012, 05:41 PM
I have some conditional formatting that changes row colors when a grid is databound. When a popup editor is invoked and then cancelled the background color of that row goes back to the default (I need to maintain it). I've tried capturing the close event like below, but that doesn't seem to work. Any suggestions?

.Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.PopUp).Window(m => m.Name("EditWindow").Title("Edit").Events(ev => ev.Close("onClose"))).TemplateName("Template"))

onClose never fires...

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 29 Oct 2012, 06:10 PM
Hi Marc,

 
Basically I suggest try using the Column template to conditionally format this column instead of interating over the Grid rows on the DataBound event. Please check the Template Overview article for more information how to conditionally format the column templates.

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Marc
Top achievements
Rank 1
answered on 30 Oct 2012, 04:30 PM
Thanks, but my DataBound function is doing other things that are not easily done with a template and I'd prefer to keep the formatting there.

Is there some working event that will capture the popup cancel? Is this a bug that OnClose is not firing?
0
Vladimir Iliev
Telerik team
answered on 31 Oct 2012, 12:36 PM
Hi Marc,

 
Please note that the Window object is currently exposed for changing the Popup Window title, and the other options currently are not serialized. In your case you should use the Edit event of the Grid to attach event handler to the Deactivate event of the Window. Please check the example below:

Grid events:

.Events(e => {
    e.DataBound("onDataBound");
    e.Edit("onEdit");
})

Grid event handlers:
function onDataBound(e) {
    //Conditional formatting on DataBound
    formatGridRows();
}
 
function onEdit(e) {
    //Bind deactivate event to the Popup window
    e.container.data("kendoWindow").bind("deactivate", function () {
        formatGridRows();
    })
}
 
function formatGridRows() {
    $("#Grid tbody tr").each(function () {
        grid = $("#Grid").data("kendoGrid");
        dataItem = grid.dataItem($(this));
 
        //Conditionally format the current row
        if (dataItem.Discontinued) {
            $(this).find(":nth-child(3):first").css("background", "red");
        }
    })
}

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Marc
Top achievements
Rank 1
answered on 31 Oct 2012, 02:44 PM
Thank you. That will work for now.
Tags
Grid
Asked by
Marc
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Marc
Top achievements
Rank 1
Share this question
or