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

Select (checkbox) column not retaining values after going to a different page.

3 Answers 921 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nathan
Top achievements
Rank 1
Nathan asked on 20 Jul 2018, 09:20 PM

I have a grid on my page, as follows:

                        @(Html.Kendo().Grid(@Model.AllChoices)

                                      .Name("choicesGrid")
                                      .Columns(columns =>
                                      {
                                          columns.Select().Width(50);
                                          columns.Bound(c => c.Name);
                                      })                         
                                      .Pageable(pageable =>
                                      {
                                          pageable
                                              .Input(true)
                                              .Numeric(false)
                                              .PageSizes(true)
                                              .PreviousNext(true);
                                      })
                                      .PersistSelection()
                                      .Sortable()
                        )

When I select rows and then go to a different page of results and then return back to the previous page, my selections are all cleared.  I have the PersistSelection option turned on for the grid. 

I have a grid on my page where Model.AllChoices is an IEnumerable of POCOs.

Any help in resolving this issue is greatly appreciated.

Thanks

 

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 23 Jul 2018, 06:49 AM
Hi Nathan,

The PersistSelection will work with AJAX binding or local data, but since you are using server binding and each paging will clear the current client-state of the Grid, the selection will be cleared.

If it is applicable for your data, you could add the following to the Grid's configuration, so that the paging could be handled on client-side;
.DataSource(dataSource => dataSource       
    .Ajax()
    .PageSize(20)
    .ServerOperation(false)       
 )

The other option would be to switch to AJAX binding:
Hope this helps.


Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Nathan
Top achievements
Rank 1
answered on 23 Jul 2018, 02:28 PM

Konstantin,

 

Thanks for your reply.  I added your recommendation and it still isn't working.  My grid now looks like:

 

 @(Html.Kendo().Grid(@Model.AllChoices)
                              .Name("choicesGrid")
                              .Columns(columns =>
                              {
                                  columns.Select().Width(50);
                                  columns.Bound(c => c.Name);
                              })                             
                              .Pageable(pageable =>
                              {
                                  pageable
                                      .Input(true)
                                      .Numeric(false)
                                      .PageSizes(true)
                                      .PreviousNext(true);
                              })
                              .PersistSelection()
                              .Sortable()
                              .DataSource(dataSource => dataSource
                                  .Ajax()
                                  .PageSize(5)
                                  .ServerOperation(false))
                              )

Do you have any other suggestions?

 

Thanks

0
Konstantin Dikov
Telerik team
answered on 24 Jul 2018, 06:17 AM
Hello Nathan,

Could you please include an ID field in the schema of the DataSource, so that each record could have unique identifier, which is mandatory for persisting the selection:


Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Nathan
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Nathan
Top achievements
Rank 1
Share this question
or