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

Custom popup editor and cell dirty flags

5 Answers 943 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gunnar
Top achievements
Rank 1
Gunnar asked on 30 Sep 2014, 08:28 AM
Hi,

I have a grid with batch inline editing but with a custom editor (a different grid in a popup window) for one of the columns. The problem is that after editing in the popup grid it removes all dirty flags on all changed cells (the red triangle in the cell's top left corner). The flags should stay but I'm doing something wrong and I just can't see it...

example: http://jsfiddle.net/nojgzu0j/1/ change for example "name" and "age" and then click in a "travelled" cell - which shows the popup and removes the red flags. 

Thanks

5 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 02 Oct 2014, 07:18 AM
Hi Gunnar,

This happens because the model's change event has been triggered, which causes the Grid to redraw the row and lose the dirty indicators. I would recommend using a template to manually insert the indicator when necessary, as shown in this example.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Gunnar
Top achievements
Rank 1
answered on 09 Oct 2014, 12:04 PM
Hi Alexander,

Thank you for the answer, the suggested solution works.

But... Is it possible to design the popup edit so it doesn't trigger a redraw of the main grid and avoid the template based solution (I have 20+ columns in production where some already have templates)?

Thanks,
Gunnar
0
Alexander Popov
Telerik team
answered on 09 Oct 2014, 12:32 PM
Hello Gunnar,

The redrawing happens automatically due to the two-way binding used by the input elements and widgets in the popup editor. The workaround would be to create a popup editor template that does not use any value bindings and utilize the Grid's save event to manually set the values of the underlying dataItem's fields.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Gunnar
Top achievements
Rank 1
answered on 09 Oct 2014, 01:07 PM
I will try that, thank you Alexander.

The template solution shows the dirty flag only for the last edited "travelled" cell - all the other cells are working as expected. Any idea why?

http://jsfiddle.net/nojgzu0j/2/

\Gunnar
0
Alexander Popov
Telerik team
answered on 13 Oct 2014, 09:26 AM
Hello again Gunnar,

Basically, the dirtyFields is not updated, hence the dirty indicator is not drawn by the template function. This could be done by utilizing the save event handler of the child Grid, for example: 
function travelEditor(container, options) {
    var grid = $("#edit-grid").data("kendoGrid");
    grid.unbind("save");
    grid.bind("save", function(e){
        if(options.model.dirtyFields){
             options.model.dirtyFields["travelled"] = true;
        }else{
            options.model.dirtyFields = { travelled : true};
        }
    })
   ...
}


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Gunnar
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Gunnar
Top achievements
Rank 1
Share this question
or