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

Client edit with batch server update with DETAILTABLES

5 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Santiago Botero
Top achievements
Rank 1
Santiago Botero asked on 17 May 2010, 10:07 AM
Hello Telerik Team,

So, I'm implementing the new "Client edit with batch server update" (on the DEMO) (the version i'm using is "2010.1.309.35"). The thing is I'm using a RadGrid with nested view tables (juste one by item in the master table) and the edition is taking place only on the detail tables.
So the matter is I can't get the new information two storage it on BDD because I can't get the control (neither TextBox nor RadDatePicker or whathever control be).

I try this :

the markup
<div id="divRadGridVehicles" class="MaintenanceGrid"
                <telerik:RadGrid ID="RadGrid_Vehicles" runat="server"  
                    AllowPaging="True" 
                    oncolumncreated="RadGrid_Vehicles_ColumnCreated"  
                    onneeddatasource="RadGrid_Vehicles_NeedDataSource"  
                    ondetailtabledatabind="RadGrid_Vehicles_DetailTableDataBind"  
                    onitemcreated="RadGrid_Vehicles_ItemCreated"  
                    onitemdatabound="RadGrid_Vehicles_ItemDataBound" > 
                    <HeaderStyle Width="70px" HorizontalAlign="Center" Font-Bold="true" BorderWidth="1px" BorderColor="White"/> 
                    <ItemStyle HorizontalAlign="Center" /> 
                    <AlternatingItemStyle HorizontalAlign="Center" /> 
                    <MasterTableView EditMode="InPlace" 
                            CommandItemDisplay="Bottom" TableLayout="Fixed"
                            <NoRecordsTemplate> 
                                <div style="height: 30px; cursor: pointer;"
                                    No items to view</div> 
                            </NoRecordsTemplate>                                         
                            <CommandItemTemplate> 
                                 <div style="height: 30px; text-align: right;"
                                        <asp:Image ID="imgCancelChanges"  
                                            runat="server"  
                                            ImageUrl="~/App_Themes/Client/Images/Maintenance/cancel.gif" 
                                            AlternateText="Cancel changes"  
                                            ToolTip="Cancel changes"  
                                            Height="24px"  
                                            style="cursor: pointer; margin: 2px 5px 0px 0px;" onclick="CancelChanges();" /> 
                                        <asp:Image ID="imgProcessChanges"  
                                            runat="server"  
                                            ImageUrl="~/App_Themes/Client/Images/Maintenance/ok.gif" 
                                            AlternateText="Process changes"  
                                            ToolTip="Process changes"  
                                            Height="24px"  
                                            style="cursor: pointer; margin: 2px 5px 0px 0px;" onclick="ProcessChanges();" /> 
                                </div>  
                            </CommandItemTemplate> 
                        <DetailTables>                         
                            <telerik:GridTableView EditMode="InPlace" ClientDataKeyNames="ID, HM_ID" DataKeyNames="ID, HM_ID" >                                                                       
                            </telerik:GridTableView>                                                                                
                        </DetailTables>             
                    </MasterTableView> 
                    <ClientSettings> 
                        <ClientEvents OnRowCreated="RowCreated"  
                            OnRowClick="RowClick"  
                            OnCommand="Grids_Command"  
                            OnGridDestroying="GridDestroying" 
                            OnRowDropping="onRowDropping" /> 
                        <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" /> 
                        <Scrolling AllowScroll="True" />                 
                    </ClientSettings>                                  
                </telerik:RadGrid> 
            </div> 

the server side code:
protected void radAjax_AjaxRequest(object sender, AjaxRequestEventArgs e)  
    {         
                //this doesn't work (return null)-------------  
                //updatedItem = RadGrid_Vehicles.MasterTableView.DetailTables[Convert.ToInt32(hmId_detailTableIndex[1])].FindItemByKeyValue("HM_ID", int.Parse(hmId_detailTableIndex[0]));  
                string keyValue = hmId_detailTableIndex[0];  
  
//----------------------------------------------------  
// this return the row but it is impossible to find the controls ------------  
  
                GridTableView nestedTableView = (RadGrid_Vehicles.MasterTableView.Items[0] as GridDataItem).ChildItem.NestedTableViews[0];  
  
               string keyValue = hmId_detailTableIndex[0];  
  
                rowItem = nestedTableView.FindItemByKeyValue("ID", (object)int.Parse(keyValue));                 
  
                UpdateDetailVehicleValues(rowItem);              
    }  
  
protected void UpdateDetailVehicleValues(GridDataItem updatedItem)  
    {  
        TextBox txtBox = new TextBox();  
        RadDatePicker radDatePicker = new RadDatePicker();  
  
//It doesn't find the control  
  
        txtBox.Text = ((TextBox)updatedItem.FindControl("txtBox_HM_ID_" + (string)updatedItem["HM_ID"].Text)).Text;  
        radDatePicker.SelectedDate = ((RadDatePicker)updatedItem[""].Controls[1]).SelectedDate;  
  
        if (updatedItem["HM_ID"].Text != "")  
        {  
            managerClient.managerMaintenance.UpdateHistoryMaintenance(  
                Convert.ToInt32(updatedItem["HM_ID"].Text),  
                txtBox.Text,  
                Convert.ToDateTime(radDatePicker.SelectedDate));  
        }  
    }  
 
 

So, how can I proceed to find the controls and get the edited information?

Best wishes,

Santiago

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 19 May 2010, 09:13 AM
Hi Santiago,

Based on the supplied code, I suspect that the problem is with the way the detail table is referenced. To see more information on the matter, please refer to the following article:

http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html

I hope this suggestion helps.

Kind regards,
Yavor
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Santiago Botero
Top achievements
Rank 1
answered on 19 May 2010, 09:52 AM
Hi Yavor,

I don't think that is the way the detail table is referenced. I can get de detail table and I can get the row which i need but without controls I added in the item_dataBound handle method. I used exactly the way to reference the detail table shown in the article:

http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html

So:
GridTableView nestedTableView = (RadGrid_Vehicles.MasterTableView.Items[0] as GridDataItem).ChildItem.NestedTableViews[0]; 

I can manage to get the information I bound initially, so the information I get from datasource, but I can't manage to get the information the user input in the textBox.

protected void UpdateDetailVehicleValues(GridDataItem updatedItem)     
    {     
//--------------------------------------------------------------------  
//this work ----------------------------------------------------------  
//-------------------------------------------------------------------  
string BoundValue = updaterItem["HM_VALUE"].Text;          
 
//----------------------------------------------------------------------------  
TextBox txtBox = new TextBox();     
RadDatePicker radDatePicker = new RadDatePicker();     
     
//It doesn't find the control     
     
        txtBox.Text = ((TextBox)updatedItem.FindControl("txtBox_HM_ID_" + (string)updatedItem["HM_ID"].Text)).Text;     
        radDatePicker.SelectedDate = ((RadDatePicker)updatedItem[""].Controls[1]).SelectedDate;     
     
        if (updatedItem["HM_ID"].Text != "")     
        {     
            managerClient.managerMaintenance.UpdateHistoryMaintenance(     
                Convert.ToInt32(updatedItem["HM_ID"].Text),     
                txtBox.Text,     
                Convert.ToDateTime(radDatePicker.SelectedDate));     
        }     
    } 


Sincerely,

Santiago
0
Santiago Botero
Top achievements
Rank 1
answered on 19 May 2010, 10:00 AM
It is possible that I try to get the controls so soon in the life page cylce ???
0
Santiago Botero
Top achievements
Rank 1
answered on 21 May 2010, 09:22 AM
I found the problem
The proble is the way the columns are bind.
The "Client edit with batch server update" works only if the columns are not autogenerated !
I managed to declare the columns in the asp mark-up and that works!!

Best regards!!
0
Accepted
Yavor
Telerik team
answered on 21 May 2010, 01:20 PM
Hello Santiago,

I am glad that the sample is working as per your requirements now.
Let us know if further issues arise.

Regards,
Yavor
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Santiago Botero
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Santiago Botero
Top achievements
Rank 1
Share this question
or