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

Passing rows from one grid to another

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 07 Oct 2015, 06:48 PM

I am having trouble passing selected rows from one grid to another. My currently implementation seems to work in Chrome but not IE. 

Currently I have 3 databound columns and 4 template columns that are static in my grid and I need to pass information that is entered into those fields to my second grid. I am currently doing this by using ajax.

 I loop through the selected rows then get the values from each column and pass the values as a string using ajaxrequest(string). As I said before this seems to work in Chrome but not IE. In IE it only seems to pass in the last row selected to the code behind, So when it binds to the second grid  it will only populate information from the last row selected. Javascript doesn't seem to tun the same in both browsers. 

Also if there is a better way then  using static columns and ajax I would love to hear it .

Here is some code.

Javascript:

function InitiateAjaxRequest(arguments) {
                   var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                   ajaxManager.ajaxRequest(arguments);
       }

 function addSelectedRows() {
            debugger;
            //SysSet('Action', <%= Actions.LoadOrder%>);
            var grid = $find("<%= rgPOLines.ClientID %>"); 
            if (grid) { 
                var MasterTable = grid.get_masterTableView(); 
                var Rows = MasterTable.get_dataItems(); 
                var selectedRows = MasterTable.get_selectedItems();
                if (selectedRows.length > 0) {
                    for (var i = 0; i < selectedRows.length; i++) { 
                        var selectedrow = selectedRows[i];                  
                        var getContainer_cnt = selectedrow.get_cell("Container_cnt"),
                            getQty_toreceive = selectedrow.get_cell("Qty_toreceive"),
                            getMfgLotNo = selectedrow.get_cell("MfgLotNo"),
                            getBin_no = selectedrow.get_cell("Bin_no");
                        //var test = $telerik.$(getQty_toreceive).find('input')[0].value;
                        //var test2 = test.replace(/,/g, "");
 
                        // Row text data
                        var Line_no = selectedrow.get_cell("Line_no").innerText,
                            Item_no = selectedrow.get_cell("Item_no").innerText,
                            Qty_remaining = selectedrow.get_cell("Qty_remaining").innerText,
                            Container_cnt = $telerik.$(getContainer_cnt).find('input')[0].value,
                            Qty_toreceive = convertToFloat($telerik.$(getQty_toreceive).find('input')[0].value) / Container_cnt,
                            Total_Qty_toreceive = $telerik.$(getQty_toreceive).find('input')[0].value,
                            MfgLotNo = $telerik.$(getMfgLotNo).find('input')[0].value,
                            Lot_no = "",
                            Bin_no = $telerik.$(getBin_no).find('span')[0].innerText;
                         
                        if (Container_cnt && Total_Qty_toreceive && MfgLotNo && (Bin_no != "Select Bin" || Bin_no)) {
                            var rowData = Line_no + "," + Item_no + "," + Qty_remaining + "," + Container_cnt + "," + Qty_toreceive + "," + Total_Qty_toreceive + "," + MfgLotNo + "," + Lot_no + "," + Bin_no
 
                            InitiateAjaxRequest(rowData); 
                            //SysSubmit(1);
                             
                        } else {
                            alert("Data must be entered in NUMBER OF CONTAINERS, QTY TO RECEIVE, and MFG LOT #.")                                                      
                        }
 
                        // Method1 
                        //var getCellText_1 = row.get_element().cells[0].innerHTML; 
                        // Method2 
                     
                        // Method3 
                        //var getCellText_2 = row.get_cell("Name").getElementsByTagName("span")[0].innerHTML; //this code also work for Checkboxcolunm, hyperlinkcolumn...etc 
                    }
                     
                } else {
                    alert("At least one row must be selected.")
                
                 
                 
            }   
             
        }

VB:

Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
        ' Remove all carriage returns from data
        Dim argument = e.Argument.Replace(vbCr, "").Replace(vbLf, "")
        ' Add data to array
 
        Dim orderNo = LTrim(RTrim(Ord_no.Value))
        Dim location = LTrim(RTrim(lblShip_to_cd.InnerText))
        Dim rowData() = argument.Split(",".ToCharArray())
        rowData = (orderNo & "," & String.Join(",", rowData) & "," & location).Split(",".ToCharArray)
 
        ' Add data to DataTable
        GetData(rowData)
 
        ' Add data to secondary grid
        BindSecondaryGrid()
    End Sub

ASPX:

<telerik:RadGrid ID="rgPOLines" runat="server" AllowPaging="false" CellSpacing="0" ShowFooter="false" GridLines="None"
                            AllowMultiRowSelection="true" OnPreRender="rgPOLines_PreRender" OnItemDataBound="rgPOLines_ItemDataBound">
 
                            <MasterTableView CommandItemDisplay="TopAndBottom" EditMode="Batch" AutoGenerateColumns="false"
                                RetrieveNullAsDBNull="true" DataKeyNames="Line_no">
 
                                <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false"
                                    ShowSaveChangesButton="false" ShowExportToExcelButton="false" ShowExportToCsvButton="false" />
                                <Columns>                                 
 
                                    <telerik:GridClientSelectColumn HeaderText="Select For Receipt" UniqueName="Item_selected"></telerik:GridClientSelectColumn>
 
                                    <telerik:GridBoundColumn DataField="Line_no" HeaderText="Line_no" UniqueName="Line_no" ReadOnly="true">
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn DataField="Item_no" HeaderText="Item_no" UniqueName="Item_no" ReadOnly="true">
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridNumericColumn DataField="Qty_remaining" HeaderText="Qty Remaining" DecimalDigits="0" UniqueName="Qty_remaining" ReadOnly="true">
                                    </telerik:GridNumericColumn>
                                     
                                    <telerik:GridTemplateColumn HeaderText="Number of Containers" UniqueName="Container_cnt" DataField="Container_cnt">   
                                        <ItemTemplate>
                                            <telerik:RadNumericTextBox ID="ContainerCnt" runat="server" MinValue="0" MaxValue="999999999"><NumberFormat GroupSeparator="" DecimalDigits="0" /></telerik:RadNumericTextBox>
                                        </ItemTemplate>                                  
                                    </telerik:GridTemplateColumn>
 
                                    <telerik:GridTemplateColumn HeaderText="Qty to Receive" UniqueName="Qty_toreceive" DataField="Qty_toreceive">   
                                        <ItemTemplate>
                                            <telerik:RadNumericTextBox ID="Qty_toreceive" runat="server" Type="Number"></telerik:RadNumericTextBox>
                                        </ItemTemplate>                                  
                                    </telerik:GridTemplateColumn>
 
                                    <telerik:GridTemplateColumn HeaderText="Mfg Lot #" UniqueName="MfgLotNo" DataField="MfgLotNo">   
                                        <ItemTemplate>
                                            <telerik:RadTextBox ID="MfgLotNo" runat="server" MaxLength="15"></telerik:RadTextBox>                                           
                                        </ItemTemplate>            
                                    </telerik:GridTemplateColumn>                                    
 
                                    <telerik:GridTemplateColumn HeaderText="Bin #" UniqueName="Bin_no">
                                        <ItemTemplate>                                           
                                             
                                            <telerik:RadDropDownList runat="server" ID="Bin_no" AutoPostBack="false" DataTextField="Bin" DataValueField="Bin">
                                            </telerik:RadDropDownList>                                                                 
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                </Columns>
                            </MasterTableView>
 
                            <ClientSettings AllowKeyboardNavigation="false" AllowColumnsReorder="false" Selecting-AllowRowSelect="true">
                                 
                            </ClientSettings>
                        </telerik:RadGrid
<telerik:RadButton ID="btnAddSelectedRows" runat="server" Text="Add Selected Rows To Receipt" OnClientClicked="addSelectedRows"
                            ToolTip="Add Selected Rows" AutoPostBack="false">
                        </telerik:RadButton>
 
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1"></telerik:RadAjaxLoadingPanel>
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" Skin="Silk" />
 
        <telerik:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgPOLines" />
                        <telerik:AjaxUpdatedControl ControlID="rgMfgLot" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rgMfgLot">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgMfgLot" />
                    </UpdatedControls>
                </telerik:AjaxSetting>                            
            </AjaxSettings>
       </telerik:RadAjaxManager>
 
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecorationZoneID="demo"
            DecoratedControls="All" EnableRoundedCorners="false" />

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 12 Oct 2015, 10:27 AM
Hello Tony,

I could assume that the problem that you are facing is due to the fact that you are initiating multiple AJAX requests if you have more than one selected item. For example, if you have two selected items and you initiate two AJAX requests, only the second one will be executed and the first one will be canceled.

For handling this I could suggest that you either pass the data for all items with one AJAX request or set the RequestQueueSize property of the RadAjaxManager to "50" for example.

Please give this a try and let me know if it resolved the issue in question.


Regards,
Konstantin Dikov
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
Tags
Grid
Asked by
Tony
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or