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

Grid closes Edit Mode on sort

2 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carl
Top achievements
Rank 1
Carl asked on 01 Jul 2009, 04:13 PM
I have a grid that defaults to edit mode.

When I sort any column, it closes out of edit mode.  How can I maintain the grid in edit mode after sorting?

Here is the NeedDataSource for the grid:

protected void rgridDemandEntry_NeedDataSource(object sender, EventArgs e) 
    { 
        if (_demand.DemandID > 0 && _gridMode == "Edit"
        { 
            _demandDT = GetDemandByDemandID(_demand.DemandID).Tables[0];  // Load the grid with the data for the demand ID 
        } 
        else 
        { 
            _demandDT = GetDemandDrgTable(0).Tables[0];  // Start a new grid with blank counts and the latest version entry 
        } 
        rgridDemandEntry.DataSource = _demandDT; // Load the datatable into rgridDemandEntry 
        for (int i = 0; i < _demandDT.Rows.Count; i++) 
        { 
            rgridDemandEntry.EditIndexes.Add(i); 
        } 
    } 


And here is the grid:
<telerik:RadGrid runat="server"  
        ID="rgridDemandEntry"  
        OnNeedDataSource="rgridDemandEntry_NeedDataSource" 
        OnItemDataBound="rgridDemandEntry_ItemDataBound" 
        OnItemCommand="rgridDemandEntry_ItemCommand" 
        Skin="Office2007"  
        AutoGenerateColumns="false" 
        AllowMultiRowEdit="true" 
        AllowPaging="false" 
        AllowSorting="true"
        <MasterTableView EditMode="InPlace" DataKeyNames="drgNum" CommandItemDisplay="TopAndBottom"
            <Columns> 
                <telerik:GridBoundColumn HeaderText="DRG #" DataField="drgNum" ReadOnly="true" /> 
                <telerik:GridBoundColumn HeaderText="MDC" DataField="mdc" ReadOnly="true" /> 
                <telerik:GridBoundColumn HeaderText="DRG Description" DataField="drgDescription" ReadOnly="true" /> 
                <telerik:GridBoundColumn HeaderText="% Req. Rehab" DataField="pctReqRehab" ReadOnly="true" /> 
                <telerik:GridBoundColumn HeaderText="Medicare DC" DataField="dischargeCountMedicare"/> 
                <telerik:GridBoundColumn HeaderText="Total DC" DataField="dischargeCount" /> 
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" Visible="false" /> 
            </Columns> 
            <CommandItemTemplate> 
                <asp:Button runat="server" ID="btnUpdate" Text="Save" CommandName="UpdateAll" ValidationGroup="VGDemandDRG" />&nbsp;&nbsp;&nbsp;&nbsp;<asp:LinkButton ID="btnCancelCurrent" runat="server" Text="Cancel" OnClick="btnCancelCurrent_Click" ForeColor="Blue" Font-Underline="true" /> 
            </CommandItemTemplate> 
        </MasterTableView> 
    </telerik:RadGrid> 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 02 Jul 2009, 05:18 AM
Hi Carl,

One suggestion would be store the key value of row in EditMode in a ViewState and update according to each EditCommand and Update/Cancel commands in ItemCommand event. And after sorting you can check for the rows that should be in EditMode and set GridDataItem's .Edit property to True in order to make that row in EditMode in the PreRender event.

-Shinu
0
Carl
Top achievements
Rank 1
answered on 02 Jul 2009, 12:06 PM
Thank you for the reply, however I'm not sure that would be the optimum solution here.

The entire grid is in edit mode.  It's a data entry style grid as users would be used to with Excel or Access.  Bascially all non-readonly columns should be in edit mode 100% of the time that the grid is visable.

The way it acts now, when I sort it actually seems to do a postback and triggers other events on the page.  Definitely not what I want to see happening.

Is there an easier way to just say ALWAYS stay in edit mode?
Tags
Grid
Asked by
Carl
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Carl
Top achievements
Rank 1
Share this question
or