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

Selected item is cleared on master row edit

4 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cookies please
Top achievements
Rank 1
cookies please asked on 09 Sep 2015, 02:24 PM

We have master-detail grids very similar to the Telerik demo here.

<telerik:RadGrid ID="MasterGrid" runat="server" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="MasterGridDataSource" GroupPanelPosition="Top" ShowGroupPanel="True">
    <ClientSettings AllowColumnsReorder="True" EnablePostBackOnRowClick="True">
        <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" />
        <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        <Resizing AllowColumnResize="True" AllowResizeToFit="True" EnableRealTimeResize="True" />
    </ClientSettings>
    <MasterTableView CommandItemDisplay="Top" DataKeyNames="OptionsID" DataSourceID="MasterGridDataSource" EditMode="InPlace" AllowMultiColumnSorting="True" ClientDataKeyNames="OptionsID" Caption="Master Grid">
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" Exportable="False">
                <HeaderStyle Width="28px" />
            </telerik:GridEditCommandColumn>
            .
            .
            .
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
 

The problem is on master row edit, the master grid SelectedItem is unselected and the child grid is cleared.

Is there any way to keep the selection when entering edit mode?

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 11 Sep 2015, 01:09 PM
Hello,

You can examine the RadGridGetAllSelectedItemsImproved.zip sample provided in the following post:
http://www.telerik.com/support/code-library/get-selected-items-through-all-pages#1eTU8nr-GUG8zfGgOGbIcA


You can also check the attached web site sample for improved performance.

Hope this helps.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
cookies please
Top achievements
Rank 1
answered on 11 Sep 2015, 07:16 PM

Thanks for the info.

That gets me half way there.  The master row remains selected when the same row goes into edit mode, but the detail grid still gets cleared.  And grid.rebind() doesn't seem to work.

We only have 1 selected row and no paging, so I modified the javascript.

var selectedRowId;
 
function Grid_OnRowSelected(sender, args) {
    selectedRowId = args.getDataKeyValue("ID");
}
 
function Grid_OnRowCreated(sender, args) {
    var id = args.getDataKeyValue("ID");
    if (selectedRowId == id) {
        args.get_gridDataItem().set_selected(true);
    }
}

0
Accepted
Eyup
Telerik team
answered on 16 Sep 2015, 10:39 AM
Hi Todd,

You can the following approach demonstrated in the attached RadGridMasterDetailClean.zip web site sample:
protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.EditCommandName)
    {
        e.Item.OwnerTableView.Items[e.Item.ItemIndex].FireCommandEvent("Select", "");
    }
}

That should do the trick. Please give it a try and let me know if it works for you.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
cookies please
Top achievements
Rank 1
answered on 16 Sep 2015, 04:30 PM

It was the PreRender event that was the magic we needed:

protected void Page_PreRender(object sender, EventArgs e)
{
    if (IsPostBack)
    {
        RadGrid2.EditItems[0].Selected = true;
    }
}

That gets us mostly there.  Cancelling/accepting edit of the master row also empties the detail grid, but this should not be an issue for our users.  And I think there is enough info in your zip file to figure out the rest.

Thanks!

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