Grid custom popup editor - distinguish Create vs Update

1 Answer 123 Views
Grid
Jordan
Top achievements
Rank 1
Iron
Jordan asked on 03 Jan 2023, 07:10 AM

I have a grid which has a custom popup editor.   When the editor opens I need to know whether I am in Edit or Create mode.   

.Editable(e=> 
    e.Mode(GridEditMode.PopUp)
    .TemplateName("CompanyOwnersEditor")
    .Window(w => {
        w.Animation(false);
        w.HtmlAttributes(new { @class = "grid-popup-window" });
        w.Name("companyOwnersEditor");
    })        
    ) 

 

When I am in Edit mode my datasource for one of my DropDownList will be different than Create.

 

I am unable how to figure this out and Model is always  null.

1 Answer, 1 is accepted

Sort by
0
Salty
Top achievements
Rank 1
Iron
answered on 06 Jan 2023, 04:55 PM

Add...

.Events(e => e.Edit("YourFunctionName"));

In the function...

function YourFunction(e) {

    if (e.model.isNew()) {
            Code that makes changes for Add
    }
    else {
            Code that makes changes for Edit
    }

}

Tags
Grid
Asked by
Jordan
Top achievements
Rank 1
Iron
Answers by
Salty
Top achievements
Rank 1
Iron
Share this question
or