Custome Grid Incell Editing

1 Answer 63 Views
Grid
Avinash
Top achievements
Rank 1
Avinash asked on 22 Nov 2024, 12:31 PM

I need a support for ,

I am working on grid custom editing , i want to show success message after successful operation.

How can I do that ? Also If there is any way if we can use inbuild save changes button.

Below is my grid.

Thanks in advance.


            @(Html.Kendo().Grid<RVNLMIS.Models.ListMasterBOQResourceCalc>()
             .Name("ResourceTypeGrid")
             .Columns(columns =>
             {

                 // Resource Type column
                 columns.Bound(c => c.RsrcType)
                     .Title("Resource Type")
                     .ClientTemplate("#= RsrcType ? RsrcType.ResourceTypeName : '' #")
                     .EditorTemplateName("ClientResource")
                     .Sortable(false)
                     .HtmlAttributes(new { style = "text-align:left" })
                     .HeaderHtmlAttributes(new { style = "text-align:left" })
                     .Width(100)
                     ;

                 // Resource Name column
                 columns.Bound(c => c.drpResource)
                     .Title("Resource")
                     .ClientTemplate("#= drpResource ? drpResource.ResourceName : ''#")
                     .EditorTemplateName("ClientSubResources")
                     .Sortable(false)
                     .HtmlAttributes(new { style = "text-align:left" })
                     .HeaderHtmlAttributes(new { style = "text-align:left" })
                     .Width(170);

                 // Quantity column
                 columns.Bound(c => c.rsrcQty)
                     .Title("Quantity")
                     .HtmlAttributes(new { style = "text-align:right" })
                     .HeaderHtmlAttributes(new { style = "text-align:right" })
                     .Width(70)
                     .Format("{0:N2}");

                 // Wastage Percentage column
                 columns.Bound(c => c.wastagePct)
                     .Title("Wastage %")
                     .HtmlAttributes(new { style = "text-align:right" })
                     .HeaderHtmlAttributes(new { style = "text-align:right" })
                     .Width(60);

                 // Total Quantity column
                 columns.Bound(c => c.TotalQty)
                     .Title("Total Qty")
                     .HtmlAttributes(new { style = "text-align:right" })
                     .HeaderHtmlAttributes(new { style = "text-align:right" })
                     .Width(80)
                     .Format("{0:N2}");

                 // Unit column
                 columns.Bound(c => c.Unit)
                     .Title("Unit")
                     .HtmlAttributes(new { style = "text-align:left" })
                     .HeaderHtmlAttributes(new { style = "text-align:left" })
                     .Width(60);

                 // Base Rate column
                 columns.Bound(c => c.BaseRate)
                     .Title("Base Rate")
                     .HtmlAttributes(new { style = "text-align:right" })
                     .HeaderHtmlAttributes(new { style = "text-align:right" })
                     .Width(80)
                     .Format("{0:N2}");

                 // Total Rate column
                 columns.Bound(c => c.TotalRate)
                     .Title("Resource Amount")
                     .HtmlAttributes(new { style = "text-align:right" })
                     .HeaderHtmlAttributes(new { style = "text-align:right" })
                     .Width(100)
                     .Format("{0:N2}");
                 columns.Command(command => command.Destroy()).Width(80);
             })
             .ToolBar(t =>
             {
                 t.Template(@<text> <b class="ml-2"> Boq Resources Details </b>
                          @item.CreateButton()
                          @item.SaveButton()
                  </text>);
             })
             .Editable(editable => editable.Mode(GridEditMode.InCell))
             .Pageable() // Pagination enabled
             .Sortable() // Sorting enabled
             .Scrollable() // Scrollable grid
             .Events(e => e.Save("onGridSave"))
             .HtmlAttributes(new { style = "height:500px;" })
             .DataSource(dataSource => dataSource
                 .Ajax()
                 .Batch(true) // Batch editing
                 .ServerOperation(false) // Client-side operations
                 .Model(model =>
                 {
                     model.Id(p => p.AutoID); // Set primary key
                     model.Field(p => p.AutoID).Editable(false); // Disable editing for AutoID
                     model.Field(p => p.RsrcType).DefaultValue(
                                 ViewData["defaultResourceType"] as RVNLMIS.Controllers.Sub_BOQController.ResourceTypeModel);
                     model.Field(p => p.drpResource).DefaultValue(new RVNLMIS.Controllers.Sub_BOQController.DrpResourceModel
                     {
                         ResourceName = "Select Resource",
                         ResourceID = 0
                     });
                 })
                 .PageSize(20) // Set page size
                 .Read(read => read.Action("GetBOQResource_Details", "Sub_BOQ").Data("getBOQId"))
                 .Create(create => create.Action("EditingCustom_Create", "Sub_BOQ"))
                 .Update(update => update.Action("EditingCustom_Update", "Sub_BOQ"))
                 .Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Sub_BOQ"))
             )
          )

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 22 Nov 2024, 01:22 PM

Hello Avinash,

 

You can use the following approach to achieve this requirement:

.DataSource(dataSource => dataSource
       .Ajax()
       .Events(e=>e.RequestEnd("handler"))
       ...
You can see all the available DataSource events here:
https://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events

I hope you will find this helpful.

 

Regards,
Eyup
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Avinash
Top achievements
Rank 1
commented on 25 Nov 2024, 05:46 AM

Hi Eyup,

 

Thanks for response , that worked perfectly!

Tags
Grid
Asked by
Avinash
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or