Pravin More

Pravin More

  • NA
  • 2.7k
  • 187.7k

Telerik: Discard newly added unsaved row on sort grid column

Oct 26 2016 3:55 AM
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:
 
 
  1. @(Html.Kendo().Grid<ProviderLanguageInfo>()  
  2. .Name("LanguageGrid")  
  3. .Columns(columns =>  
  4. {  
  5. columns.Bound(p => p.ProviderLanguageId).Visible(false);  
  6. columns.Bound(p => p.HealthSystemId).Visible(false);  
  7. columns.Bound(p => p.ProviderId).Visible(false);  
  8. columns.Bound(p => p.IsDeleted).Visible(false);  
  9.   
  10. columns.Bound(p => p.Language).ClientTemplate("#=Language.LanguageName#").Title("Language").EditorTemplateName("LanguageList");  
  11. columns.Bound(p => p.LanguageAbility).ClientTemplate("#=LanguageAbility.LanguageAbilityTypeName#").Title("Ability").EditorTemplateName("LanguageAbilityList");  
  12. columns.Bound(p => p.LanguageProficiency).ClientTemplate("#=LanguageProficiency.LanguageProficiencyTypeName#").Title("Proficiency").EditorTemplateName("LanguageProficiencyList");  
  13. if (hasRights)  
  14. columns.Command(command =>  
  15. {  
  16. command.Edit();  
  17. command.Destroy();  
  18. }).Width(250).Title("Action");  
  19. })  
  20. .ToolBar(toolbar => { if (hasRights) toolbar.Create().Text("Add New Language"); })  
  21. .Events(evt =>  
  22. {  
  23. evt.Edit("onGridEdit");  
  24. evt.DataBound("onGridDataBound");  
  25. })  
  26. .Editable(editable => editable.Mode(GridEditMode.InLine))  
  27. .Pageable()  
  28. .Scrollable()  
  29. .Sortable()  
  30. .HtmlAttributes(new {style = "height:110px;"})  
  31. .DataSource(dataSource => dataSource  
  32. .Ajax()  
  33. .ServerOperation(false)  
  34. .PageSize(3)  
  35. .Events(events =>  
  36. {  
  37. //events.Error("error_handler");  
  38. events.RequestEnd("onGridRequestEnd");  
  39. })  
  40. .Model(model =>  
  41. {  
  42. model.Id(p => p.ProviderLanguageId);  
  43. model.Field(p => p.Language).DefaultValue(defaultLanguage);  
  44. model.Field(p => p.LanguageAbility).DefaultValue(defaultAbility);  
  45. model.Field(p => p.LanguageProficiency).DefaultValue(defaultProficiency);  
  46. model.Field(p => p.ProviderId).DefaultValue(Model.ProviderId);  
  47. model.Field(p => p.HealthSystemId).DefaultValue(Model.HealthSystemId);  
  48. })  
  49. .Read(read => read.Action("GetProviderLanguages""Language"new {providerId = Model.ProviderId}))  
  50. .Update(update => update.Action("UpdateLanguage""Language"))  
  51. .Destroy(destroy => destroy.Action("DeleteLanguage""Language"))  
  52. .Create(create => create.Action("CreateLanguage""Language"))  
  53. )  
  54. )  

Answers (1)