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

Grid's Destroy command trigger the dataBound event unexpectedly

3 Answers 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Veteran
Iron
Chris asked on 08 Aug 2018, 09:05 AM

HI

dataBound
Fired when the widget is bound to data from its data source.

But why the Destroy command trigger the dataBound event too ??? 

*XXXXX_Read method not executed while the Destroy command clicked.

-- 

Incell mode

    @(Html.Kendo().Grid<MyCompany.Entity.Models.TXXXXX>)
      .Name("XXXXXGrid")
      ...
      .Pageable(pageable => pageable.Enabled(false))
      .Columns(columns =>
      {
        ...
        columns.Command(command => command.Destroy().Text("Delete")).Width(100);
      })
      .DataSource(dataSource =>
      {
        dataSource
          .Ajax()
          .Batch(true)
          //.PageSize(GridConst.PAGE_SIZE)
          .Model(model =>
          {
            model.Id(m => m.UniqueID);
          })
          .ServerOperation(false)
          .Read(read => read.Action("XXXXX_Read", "XXX").Data("xxxxx.filterXXXXXGrid"))
          .Events(events =>
          {
            ...
          });
      })
      .Events(events =>
      {
        events.Change("xxxxx.XXXXXGrid_Change");
        events.DataBound("xxxxx.XXXXXGrid_DataBound");
        events.Edit("xxxxx.XXXXXGrid_Edit");
      })
      .HtmlAttributes(new { @style = "height: 100%; min-height: 180px" }))

*Visual Studio 2015
*Telerik DevCraft 2017.2.621.545 (UI for ASP.NET MVC).

Best regards

Chris

 

 


3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 09 Aug 2018, 10:51 AM
Hi Chris,

Out of the box each data-related operation in the Grid will raise the dataBound event. When data is removed from the Grid and persisted to the server the deleted items are returned back to the client. This way the data in the Grid can reflect correctly what is removed. 

With that said, would you elaborate in more detail what is the functionality you would like to implement? Having better understanding of your goal will enable us to provide more to-the-point suggestions on how it can be implemented.


Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Chris
Top achievements
Rank 1
Veteran
Iron
answered on 09 Aug 2018, 01:53 PM

´╝×When data is removed from the Grid and persisted to the server...

The sample above, the Batch(true) was used and not yet persisted to the server. Destroy the record locally should not trigger the dataBound event.

Best regards

Chris

 

0
Georgi
Telerik team
answered on 13 Aug 2018, 09:57 AM
Hello Chris,

When any change occurs in the DataSource (sorting, paging, grouping, item is modified, etc.) the change event of the DataSource is triggered. Within the change event handler the grid is rebound in order to display the current state of the data.

When the user presses the Save Changes button all pending changes are sent to the server. However, in order the grid to display the latest state of the data before the pending changes are sent to the server, it is necessary to rebind it.


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Veteran
Iron
Answers by
Viktor Tachev
Telerik team
Chris
Top achievements
Rank 1
Veteran
Iron
Georgi
Telerik team
Share this question
or