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

Two Grids on one page

3 Answers 716 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Veteran
Andrey asked on 15 Apr 2020, 11:27 AM

Hello,

I have two grids on one page. The first one has SelectionMode="GridSelectionMode.Single" and the second one is re-reading the data (SQL) based on this selection. I am using Single Selection and handling the SelectedItemsChanged event. This works fine except the first grid is not unselecting the previously selected row so now it displays all previously selected rows.

Click on first grid first row. First grid first row selected. Grid2 content refreshed. That's fine.

Click on first grid second row. First grid second row selected. Grid2 content refreshed. But the grid1 first row is still selected.

I am using UI Kendo 2.1.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Andrey
Top achievements
Rank 1
Veteran
answered on 15 Apr 2020, 11:30 AM

Here is the code:

    <div class="col-md-4">
        <TelerikGrid Data="@Insurers" Height="400px"
            Sortable="true"
            FilterMode="GridFilterMode.FilterRow"
            SelectionMode="GridSelectionMode.Single"
            SelectedItemsChanged="@((IEnumerable<InsurerVM> insurerVMList) => OnSelectInsurerAsync(insurerVMList))"
            Resizable="true"
            Reorderable="true"
            ScrollMode="@GridScrollMode.Virtual"
            Pageable="false"
            RowHeight="40">
            <GridColumns>
                <GridColumn Field="@(nameof(InsurerVM.Name))" Title="Insurance Company" Width="200px" />
                <GridColumn Field="@(nameof(InsurerVM.Counter))" Title="Counter" Filterable="false" Width="70px" />
                <GridColumn Field="@(nameof(InsurerVM.Selected))" Title="Selected" Filterable="false" Width="75px" />
            </GridColumns>
        </TelerikGrid>
    </div>
    <div class="col-md-4">
        <TelerikGrid Data="@SubAccounts" Height="400px"
            Sortable="true"
            FilterMode="GridFilterMode.FilterRow"
            SelectionMode="GridSelectionMode.Single"
            Resizable="true"
            Reorderable="true"
            ScrollMode="@GridScrollMode.Virtual"
            Pageable="false"
            RowHeight="40">
            <GridColumns>
                <GridColumn Field="@(nameof(SubAccountVM.Name))" Title="Product" Width="200px" />
                <GridColumn Field="@(nameof(SubAccountVM.Counter))" Title="Counter" Filterable="false" Width="70px" />
                <GridColumn Field="@(nameof(SubAccountVM.Selected))" Title="Selected" Filterable="false" Width="75px" />
            </GridColumns>
        </TelerikGrid>

    </div>

0
Marin Bratanov
Telerik team
answered on 15 Apr 2020, 11:47 AM

Hello Andrey,

Could you compare against this example to see what is the difference causing the issue: https://docs.telerik.com/blazor-ui/components/grid/selection/single#selecteditemschanged-event? If this does not help you resolve it, can you post here a runnable version of the snippet that I can investigate?

Also, please make sure that the upgrade to 2.10.0 went well and that any CDN references are also updated: https://docs.telerik.com/blazor-ui/upgrade/overview

On a side note, in a Blazor scenario you should use Telerik UI for Blazor, the Kendo UI suite is not designed for Blazor.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Andrey
Top achievements
Rank 1
Veteran
answered on 15 Apr 2020, 02:36 PM

Hi Marin,

Thank you for quick answer. I've found my problem. Grid2 getting data method should be sync. It was async Task.

sync Task OnSelectFirstGrid(...)

{

SecondGridData = await GetDataAsync(...) //Error: multiple selection in first grid

SecondGridData = GetData(...) //Works fine

}

 

Tags
Grid
Asked by
Andrey
Top achievements
Rank 1
Veteran
Answers by
Andrey
Top achievements
Rank 1
Veteran
Marin Bratanov
Telerik team
Share this question
or