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

Persisting Cell Edit on Update

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 26 Feb 2015, 09:47 PM
I have a simple radgrid (markup below) that is populated with a DataTable, such as the example below;

Flag  Rank
J        3
X       8

In the edit mode I want to change the values of the Rank column, and on update I want the grid to reflect the new value. I don't want to post the value back to the original datasource - I just want it to persist in the radgrid.  In another operation I will use the values in the radgrid after the user makes their edits.

I imagine this is simple to do but I am not seeing it.  Can you point me in the right direction?

protected void rgFlagsToRerank_UpdateCommand(object sender, GridCommandEventArgs e)
{
    GridEditableItem editedItem = e.Item as GridEditableItem;
    Hashtable newValues = new Hashtable();
    e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
    int valRank = int.Parse(newValues["Rank"].ToString());
     
    //todo - help please - how do I persist this value in the grid
 
}



<telerik:RadGrid ID="rgFlagsToRerank" runat="server" CellSpacing="0" GridLines="Both" Font-Names="Arial" Font-Size="8pt" Height="400" Width="310px"  AutoGenerateColumns="false" OnCancelCommand="rgTotalVsDissolved_CancelCommand"
                                            OnNeedDataSource="rgFlagsToRerank_NeedDataSource" OnUpdateCommand="rgFlagsToRerank_UpdateCommand" >
                                            <ClientSettings >
                                                <Scrolling AllowScroll="True" UseStaticHeaders="True"  />                                                                                                                                                         
                                            </ClientSettings>
                                            <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true"  ></ExportSettings>
                                            <MasterTableView Width="310px" Caption="Flags to Re-rank" EditMode="InPlace" CommandItemDisplay="Top" NoMasterRecordsText="No validation flags to re-rank"
                                                DataKeyNames="ValidationFlags,Rank"
                                                >
                                                <Columns>                                                       
                                                    <telerik:GridBoundColumn DataField="ValidationFlags" UniqueName="ValidationFlags" Display="true" HeaderText="Validation Flag" HeaderStyle-Width="100" ItemStyle-Width="95" ReadOnly="true"  ></telerik:GridBoundColumn>  
                                                    <telerik:GridBoundColumn DataField="Rank" UniqueName="Rank" Display="true" HeaderText="Rank" HeaderStyle-Width="100" ItemStyle-Width="95"   ></telerik:GridBoundColumn>                    
                                                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="Edit" HeaderStyle-Width="100px"  UpdateText="Update" CancelText="Cancel"></telerik:GridEditCommandColumn>
                                                </Columns>
                                                <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false"  ShowRefreshButton="false"  ></CommandItemSettings>                                       
                                                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </RowIndicatorColumn>
                                                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </ExpandCollapseColumn>
                                                <EditFormSettings>
                                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                    </EditColumn>
                                                </EditFormSettings>
                                            </MasterTableView>
                                            <FilterMenu EnableImageSprites="False"></FilterMenu>
                                        </telerik:RadGrid>



1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 03 Mar 2015, 01:09 PM
Hello Dan,

If you need to persist the changed of the grid only for the current user's session, you will have to store your DataTable in a Session variable and change the values manually on Update/Insert or Delete commands of the grid. Once you store the DataTable in a Session variable, you will pass that object as a data source of the grid within the OnNeedDataSource event.

Please note that RadGrid will work with the data that is provided to it and it is up to the developer to handle any changes on the data source (unless you have a properly configured DataSource control that will allow automatic CRUD operations).

For storing a DataTable in the Session, you could refer to the following forum threads:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or