I am using telerik grid in my mvc web application.
My Scinario is like-
1.I click "add new row" option which adds empty row in my grid.
2. Then I click on sort one of column without saving newly added row.
So this sort saves newly added row automatically.I want to override this behavior by discarding unsaved row.
Let me know how to do this.
Below is my grid defination:
- @(Html.Kendo().Grid<ProviderLanguageInfo>()
- .Name("LanguageGrid")
- .Columns(columns =>
- {
- columns.Bound(p => p.ProviderLanguageId).Visible(false);
- columns.Bound(p => p.HealthSystemId).Visible(false);
- columns.Bound(p => p.ProviderId).Visible(false);
- columns.Bound(p => p.IsDeleted).Visible(false);
-
- columns.Bound(p => p.Language).ClientTemplate("#=Language.LanguageName#").Title("Language").EditorTemplateName("LanguageList");
- columns.Bound(p => p.LanguageAbility).ClientTemplate("#=LanguageAbility.LanguageAbilityTypeName#").Title("Ability").EditorTemplateName("LanguageAbilityList");
- columns.Bound(p => p.LanguageProficiency).ClientTemplate("#=LanguageProficiency.LanguageProficiencyTypeName#").Title("Proficiency").EditorTemplateName("LanguageProficiencyList");
- if (hasRights)
- columns.Command(command =>
- {
- command.Edit();
- command.Destroy();
- }).Width(250).Title("Action");
- })
- .ToolBar(toolbar => { if (hasRights) toolbar.Create().Text("Add New Language"); })
- .Events(evt =>
- {
- evt.Edit("onGridEdit");
- evt.DataBound("onGridDataBound");
- })
- .Editable(editable => editable.Mode(GridEditMode.InLine))
- .Pageable()
- .Scrollable()
- .Sortable()
- .HtmlAttributes(new {style = "height:110px;"})
- .DataSource(dataSource => dataSource
- .Ajax()
- .ServerOperation(false)
- .PageSize(3)
- .Events(events =>
- {
-
- events.RequestEnd("onGridRequestEnd");
- })
- .Model(model =>
- {
- model.Id(p => p.ProviderLanguageId);
- model.Field(p => p.Language).DefaultValue(defaultLanguage);
- model.Field(p => p.LanguageAbility).DefaultValue(defaultAbility);
- model.Field(p => p.LanguageProficiency).DefaultValue(defaultProficiency);
- model.Field(p => p.ProviderId).DefaultValue(Model.ProviderId);
- model.Field(p => p.HealthSystemId).DefaultValue(Model.HealthSystemId);
- })
- .Read(read => read.Action("GetProviderLanguages", "Language", new {providerId = Model.ProviderId}))
- .Update(update => update.Action("UpdateLanguage", "Language"))
- .Destroy(destroy => destroy.Action("DeleteLanguage", "Language"))
- .Create(create => create.Action("CreateLanguage", "Language"))
- )
- )