Hi, I'm using some grids to select registers and send to controller, whatever, when I select a row and search or sorting all selected rows change to unselected.
Bellow there is a example of one of this grids:
<ejs-grid id="GridAlunoCortesia"
dataSource="@Model.GridListAlunoCortesia"
allowFiltering="true"
allowSorting="true"
locale="pt-BR"
toolbar="@(new List<string>() {"Search"})"
toolbarClick="toolbarClick"
allowSelection="true"
dataBound="dataBoundAlunoCortesia"
rowDataBound="rowDataBoundAlunoCortesia"
>
<e-grid-selectionsettings type="Multiple" persistSelection="false"></e-grid-selectionsettings>
<e-grid-filterSettings type="Excel"></e-grid-filterSettings>
<e-grid-columns>
<e-grid-column type="checkbox" width="50"></e-grid-column>
<e-grid-column field="Id" headerText="Id" isPrimaryKey="true" visible="false" textAlign="Justify" min-width="60" width="60"></e-grid-column>
<e-grid-column field="AlunoId" headerText="AlunoId" visible="false" textAlign="Justify" min-width="60" width="60"></e-grid-column>
<e-grid-column field="AlunoNome" headerText="Aluno" textAlign="Left" min-width="200" width="250"></e-grid-column>
<e-grid-column field="TurmaNome" headerText="Turma" textAlign="Left" min-width="200" width="250"></e-grid-column>
<e-grid-column field="Produto" headerText="OperacaoId" visible="false" textAlign="Justify" min-width="60" width="60"></e-grid-column>
<e-grid-column field="Selecionado" visible="false"></e-grid-column>
</e-grid-columns>
</ejs-grid>
To Select data based on the model I use the functions bellow:
var selIndexAlunoCortesia = [];
function rowDataBoundAlunoCortesia(args) {
if (args.data['Selecionado'] === true) {
selIndexAlunoCortesia.push(parseInt(args.row.getAttribute('aria-rowindex')));
}
}
function dataBoundAlunoCortesia(args) {
if(_inicialiazado1 == false)
{
if (selIndexAlunoCortesia.length) {
this.selectRows(selIndexAlunoCortesia);
selIndexAlunoCortesia = [];
}
}
}
Hi Fillipe,
Thanks for contacting Syncfusion support.
By default, the selection will be removed when we perform any data actions like Paging, Sorting, Filtering, Searching, Refresh, etc., in the Grid.
If ‘persistSelection’ is set to true, then the Grid selection is persisted on all the operations. For persisting selection in the Grid, any one of the columns should be enabled as a primary key. The primaryKey field should contain unique values in the dataSource.
The checkbox type column is mandatory for the persistSelection feature.
https://ej2.syncfusion.com/aspnetcore/documentation/grid/selection/check-box-selection
|
<e-grid-selectionsettings type="Multiple" persistSelection="true"></e-grid-selectionsettings> <e-grid-columns> <e-grid-column type="checkbox" width="50"></e-grid-column> <e-grid-column field="Id" headerText="Id" isPrimaryKey="true" visible="false" textAlign="Justify" min-width="60" width="60"></e-grid-column> </e-grid-columns> </ejs-grid>
|
Please get back to us if you need further assistance with this.
Regards,
Rajapandiyan S
Hi, I try to use the persistSelection="true", but when it`s true and I click to order for example, all rows got selected.
Thanks for now...
Hi Fillipe,
Thanks for the update.
We have prepared a simple sample with your code example and the selections are working fine from our side. Find the below sample for your reference.
Kindly share the following details to replicate the issue.
Regards,
Rajapandiyan S