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

How to save data from the entire RadGrid at one Time

5 Answers 447 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Judith Murgia
Top achievements
Rank 1
Judith Murgia asked on 18 Aug 2010, 02:45 AM
Hi Telerik Team (or anyone else who can help),

I have spent all day searching to the ends of the internet to try to find out how to save all the data from a RadGrid at once. I have found many other people who want to do this, but cannot find a good answer as to how! I also have another post about this topic but no one has replied........... can it be done!

It is easy to populate the whole grid at one time, but as I have read many times about all the  Automatic Grid Saving Stuff there is no mention of how to save the whole grid at one time.  Our users want us to present them with a grid to fill in, then after they look at the whole thing and make sure they have everything correct - then they want us to save it. They don't want us to save one row at a time. Our upper management can't believe that there isn't a simple way to do this and right now they aren't thinking very highly of the Telerik package  they bought us!

We have a grid represented in the code below, and it loads great, and works great if you click on a row, edit it, then click on another row and it saves, but they don't want that. i was able to put a few lines of code in the page load that will make the whole grid editable, but then how do we save it? 

Is there a nice way I can use the Telerik RadGrid auto save stuff to save each row - maybe a loop to access each row then do something?  If I could have a save button then if that button is pressed execute a loop to access each row and call the UpdateCommand for each that would work but we can't quite figure out how to do it.

Here is my grid code, please let me know if you would like me to provide anything else:

Also - if there is a better way to do it, something else besides a grid to display data, edit then save it please let me know.

<body class="BODY">
    <form runat="server" id="mainForm" method="post" style="width: 100%;">
        <%--<telerik:Header runat="server" ID="Header1" NavigationLanguage="VB"></telerik:Header>--%>
        <!-- content start -->
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
        <!--
            var hasChanges, inputs, dropdowns, editedRow;
              
            function RowClick(sender, eventArgs)
            {
                if(editedRow && hasChanges)
                {
                    hasChanges = false;
                    if(confirm("Update changes?"))
                    {
                          
                        $find("<%= RadGrid1.MasterTableView.ClientID %>").updateItem(editedRow);
                    }
                }
                              
            }
  
            function RowDblClick(sender, eventArgs)
            {
                editedRow = eventArgs.get_itemIndexHierarchical();
                $find("<%= RadGrid1.MasterTableView.ClientID %>").editItem(editedRow);
            }
  
            function GridCommand(sender, args)
            {
                if (args.get_commandName() != "Edit")
                {
                    editedRow = null;
                }
            }
  
            function GridCreated(sender, eventArgs)
            {
                var gridElement = sender.get_element();
                var elementsToUse = [];
                inputs = gridElement.getElementsByTagName("input");
                for (var i = 0; i < inputs.length;i++)
                {
                    var lowerType = inputs[i].type.toLowerCase();
                    if(lowerType == "hidden" || lowerType == "button")
                    {
                        continue;
                    }
                      
                    Array.add(elementsToUse, inputs[i]);
                    inputs[i].onchange = TrackChanges;
                }
                  
                dropdowns = gridElement.getElementsByTagName("select");
                for (var i = 0; i < dropdowns.length;i++)
                {
                    dropdowns[i].onchange = TrackChanges;
                }
  
                setTimeout(function(){if(elementsToUse[0])elementsToUse[0].focus();},100);
            }
  
            function TrackChanges(e)
            {
                hasChanges = true;
            }
        --> 
    </script>
    </telerik:RadCodeBlock>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="Label1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadGrid 
            ID="RadGrid1" 
            DataSourceID="SessionDataSource1" 
            OnItemDataBound = "RadGrid1_ItemDataBound"
            Width="97%"
            ShowStatusBar="True" 
            AllowSorting="True" 
            PageSize="15" 
            GridLines="None" 
            AllowPaging="True"
            runat="server" 
            AllowAutomaticUpdates="True" 
            AutoGenerateColumns="False">
            <MasterTableView 
                        TableLayout="Fixed" 
                        DataKeyNames="checklistNo" 
                        EditMode="InPlace" >
              <Columns>
                <telerik:GridBoundColumn UniqueName="CategoryID" DataField="CategoryID" HeaderText="CategoryID" Display="false" ReadOnly="True" >
                    <HeaderStyle Width="10%" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="checklistNo" DataField="checklistNo" HeaderText="checklistNo"  Display="False" ReadOnly="True" >
                    <HeaderStyle Width="25%" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="Related_item_type_label" DataField="Related_item_type_label" HeaderText="Question"  ReadOnly="True">
                    <HeaderStyle Width="30%" />
                </telerik:GridBoundColumn>
                 <telerik:GridTemplateColumn>
                    <HeaderStyle Width="10%" />   
                    <ItemStyle Width="10%" />
                    <HeaderTemplate>     
                        <asp:Label ID="lblHeaderServiceImpact" Text="Service Impact" runat="server"></asp:Label>     
                    </HeaderTemplate>
                    <ItemTemplate>     
                        <asp:Label ID="lblServiceImpact1" Text='<%#Eval("Service_impact_category")%>' runat="server"></asp:Label>     
                    </ItemTemplate>     
                    <EditItemTemplate>
                       <telerik:RadTextBox AutoPostBack="true"  ReadOnly="true" ID="lbllblServiceImpact" runat="server"  Text='<%#Eval("Service_impact_category")%>' BorderStyle="None">
                       </telerik:RadTextBox>
                    </EditItemTemplate>
                 </telerik:GridTemplateColumn>
                 <telerik:GridTemplateColumn>
                    <HeaderStyle Width="17%" />   
                    <ItemStyle Width="17%" />
                    <HeaderTemplate>     
                        <asp:Label ID="lblHeaderInspectionResult" Text="Inspection Result" runat="server"></asp:Label>     
                    </HeaderTemplate>
                    <ItemTemplate>     
                        <asp:Label ID="lblInspectionResult1" Text='<%#Eval("INSPECTION_RESULT")%>' runat="server"></asp:Label>     
                    </ItemTemplate>     
                    <EditItemTemplate>
                       <telerik:RadTextBox AutoPostBack="true" visible="False" ID="lblInspectionResult" runat="server"  Text='<%#Eval("INSPECTION_RESULT")%>'>
                       </telerik:RadTextBox>
                       <telerik:RadComboBox visible="True" ID="cbInspectionResult" AppendDataBoundItems="true" runat="server"  >
                       </telerik:RadComboBox>
                    </EditItemTemplate>
                 </telerik:GridTemplateColumn>
                 <telerik:GridTemplateColumn>
                    <HeaderStyle Width="17%" />   
                    <ItemStyle Width="17%" />
                    <HeaderTemplate>     
                        <asp:Label ID="lblHeaderInspectionFault" Text="Inspection Fault" runat="server"></asp:Label>     
                    </HeaderTemplate>
                    <ItemTemplate>     
                        <asp:Label ID="lblInspectionFault1" Text='<%#Eval("INSPECTION_FAULT")%>' runat="server"></asp:Label>     
                    </ItemTemplate>     
                    <EditItemTemplate>
                       <telerik:RadTextBox AutoPostBack="true" visible="False" ID="lblInspectionFault" runat="server"  Text='<%#Eval("INSPECTION_FaULT")%>'>
                       </telerik:RadTextBox>
                       <telerik:RadComboBox visible="True" ID="cbInspectionFault" AppendDataBoundItems="true" runat="server"  >
                       </telerik:RadComboBox>
                    </EditItemTemplate>
                 </telerik:GridTemplateColumn>
                 <telerik:GridTemplateColumn>
                    <HeaderStyle Width="20%" />   
                    <ItemStyle Width="20%" />
                    <HeaderTemplate>     
                        <asp:Label ID="lblInspectionCommentHeader" Text="Comments" runat="server"></asp:Label>     
                    </HeaderTemplate>
                    <ItemTemplate>     
                        <asp:Label ID="lblInspectionComment" Text='<%#Eval("INSPECTION_COMMENT")%>' runat="server"></asp:Label>     
                    </ItemTemplate>     
                    <EditItemTemplate>
                       <telerik:RadTextBox  Width="100%" AutoPostBack="true" visible="True" ID="txtInspectionComment" runat="server"  Text='<%#Eval("INSPECTION_COMMENT ")%>'>
                       </telerik:RadTextBox>
                    </EditItemTemplate>
                 </telerik:GridTemplateColumn>
              </Columns>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents 
                    OnRowClick="RowClick"
                    OnRowDblClick="RowDblClick"
                    OnGridCreated="GridCreated" 
                    OnCommand="GridCommand" />
            </ClientSettings>
        </telerik:RadGrid>
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="180px" />
        <telerik:GridDropDownListColumnEditor ID="GridDropDownListColumnEditor1" runat="server" DropDownStyle-Width="70px" />
        <telerik:GridCheckBoxColumnEditor ID="GridCheckBoxColumnEditor1" runat="server" CheckBoxStyle-BorderWidth="2" />
        <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="50px" />
        <br />
        <asp:Label ID="Label1" runat="server" EnableViewState="false" />
        <br />
        <asp:SqlDataSource 
            ID="SessionDataSource1"
            runat="server" 
            ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"
            ProviderName="<%$ ConnectionStrings:OracleConnectionString.ProviderName %>" 
            SelectCommand="SELECT categoryid, category_name, checklistNo, ROWNUM || ') ' || related_item_type_label AS related_item_type_label, inspection_Result, inspection_fault, service_impact_category, inspection_comment FROM ( SELECT categoryid || ' - ' || category_name categoryid, category_name, checklistNo, MAX( related_item_type_label ) AS related_item_type_label, MAX( inspection_Result ) AS inspection_Result,MAX( inspection_fault ) AS inspection_fault, MAX( service_impact_category ) AS service_impact_category, MAX( inspection_comment ) AS inspection_comment FROM(SELECT categoryid,category_name,checklistNo,DECODE( INSTR( related_item_type,'INSPECTION_RESULT'),0,NULL, related_item_type_label ) related_item_type_label,DECODE( INSTR( related_item_type,'INSPECTION_RESULT'),0,NULL, DECODE( related_item_value, NULL, default_value, related_item_value ) ) inspection_Result,DECODE( INSTR( related_item_type,'INSPECTION_FAULT'),0,NULL, DECODE( related_item_value, NULL, default_value, related_item_value ) ) inspection_fault,DECODE( INSTR( related_item_type,'SERVICE_IMPACT_CATEGORY'),0,NULL, DECODE( related_item_value, NULL, default_value, related_item_value ) ) service_impact_category,DECODE( INSTR( related_item_type,'INSPECTION_COMMENT'),0,NULL, DECODE( related_item_value, NULL, default_value, related_item_value ) ) inspection_comment FROM( SELECT v.view_name,v.item_type_order,v.related_item_type_label,v.related_item_type,SUBSTR(v.related_item_type, -5) checklistNo,d.related_item_value,( SELECT valid_type_rule_value FROM pimmds.valid_type_rules r WHERE r.valid_type_rule = 'VALID VALUE DEFAULT' AND r.item_type = v.related_item_type AND SYSDATE BETWEEN r.effectivity_in AND r.effectivity_out ) default_value, d.created_by, DECODE( c.categoryid,NULL,'91',c.categoryid) AS categoryid,c.category_name FROM PIMMDS.relationship_views v,( SELECT a.item_type, a.item_value, b.item_type related_item_type, b.item_value related_item_value, c.created_by FROM pimods.items a, pimods.items b, pimods.relationships c WHERE a.item_no = c.parent_item_no AND b.item_no = c.child_item_no AND a.item_type = 'INSPECTION_SEQUENCE_NUMBER' AND a.item_value = :ISN AND SYSDATE BETWEEN c.effectivity_in AND c.effectivity_out) d,(SELECT SUBSTR(related_item_type,-2) categoryid, related_item_type_value category_name FROM pimmds.relationship_views v WHERE view_name = 'Clearwire Quality Control Checklist' AND related_item_type LIKE 'INSPECTION_CATEGORY%' AND SYSDATE BETWEEN v.effectivity_in AND v.effectivity_out ) c WHERE v.view_name = 'Clearwire Quality Control Checklist Update' AND ( v.related_item_type LIKE 'INSPECTION_RESULT%' OR v.related_item_type LIKE 'INSPECTION_FAULT%' OR v.related_item_type LIKE 'SERVICE_IMPACT_CATEGORY%' OR v.related_item_type LIKE 'INSPECTION_COMMENT%') AND substr(v.related_item_type,-5,2) = :CATEGORYID AND v.item_type = d.item_type (+) AND v.related_item_type = d.related_item_type (+) AND SUBSTR( v.related_item_type,-5,2) = c.categoryid (+) ) ) GROUP BY categoryid, category_name,checklistNo ORDER BY checklistNo )"
            UpdateCommand="PIMMDS.QC_PROCESS_DATA_FLOW.deltaRDSInspection"
            OldValuesParameterFormatString="original_{0}"
            ConflictDetection="CompareAllValues"
            UpdateCommandType="StoredProcedure">
            <UpdateParameters>
                <asp:Parameter Name="L_INSPECTION_SN" Type="String" />
                <asp:Parameter Name="L_LINE" Type="String" />
                <asp:Parameter Name="L_RESULTS" Type="String" />
                <asp:Parameter Name="L_FAULTS" Type="String" />
                <asp:Parameter Name="L_COMMENTS" Type="String" />
            </UpdateParameters>
            <SelectParameters>
                <asp:Parameter Name="ISN" Type="String" Direction="Input" />
                <asp:Parameter Name="CATEGORYID" Type="String" Direction="Input" />
            </SelectParameters>
        </asp:SqlDataSource>
        <!-- content end -->
        <%--<telerik:Footer runat="server" ID="Footer1"></telerik:Footer>--%>
    <table>
                <tr>
                <td> </td><td> </td><td> </td> <td> </td>
                    <td align="center" >
                        <asp:Button  ID="btnsave" runat="server" OnClick="btnsave_click" Font-Size="Small" causesvalidation="false" Text="Save Data" /> </td>
                </tr>
    </table>
    </form>
</body>

 

 

5 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 20 Aug 2010, 01:32 PM
Hello Judith,

Please take a look at the following resources explaining how the desired functionality can be implemented:
Performing batch updates
Excel-like RadGrid

I hope this helps.

Regards,
Mira
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
Gaétanne
Top achievements
Rank 1
answered on 30 Sep 2010, 02:37 PM
Do you have the same example Excel like RAdGrid in VB.net
I wonder if Judith have find something that work. I have the same problem that you have. It's been a two month now that i trying to find a way to make that grid work.
0
Mira
Telerik team
answered on 05 Oct 2010, 12:41 PM
Hello GaƩtanne,

Please try using this code converter to convert the code of the Excel-like RadGrid code library to VB.

If the issues persist, please provide more information on your scenario and we will do our best to help.

Best wishes,
Mira
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
Gaétanne
Top achievements
Rank 1
answered on 05 Oct 2010, 07:16 PM
I have converted the code from C# to Vb but i have this code that give me error. Please can you correct this and send me the good code for VB.

Thank you

RadScriptManager1.RegisterStartupScript(Page.Page.[GetType](), "init", "colls = " + columnsCount + ";rows=" + itemsCount + ";", True)
0
Mira
Telerik team
answered on 07 Oct 2010, 04:00 PM
Hello GaƩtanne,

Please try using the following code:
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "init", "colls = " & columnsCount & ";rows=" & itemsCount & ";", True)

I hope it helps.

Best wishes,
Mira
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
Judith Murgia
Top achievements
Rank 1
Answers by
Mira
Telerik team
Gaétanne
Top achievements
Rank 1
Share this question
or