Passing rows from one grid to another

2 posts, 0 answers
  1. Tony
    Tony avatar
    4 posts
    Member since:
    Jun 2014

    Posted 07 Oct 2015 Link to this post

    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.


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

     function addSelectedRows() {
                //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
                            } 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.")


    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
            ' Add data to secondary grid
        End Sub


    <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" />
                                        <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 DataField="Item_no" HeaderText="Item_no" UniqueName="Item_no" ReadOnly="true">
                                        <telerik:GridNumericColumn DataField="Qty_remaining" HeaderText="Qty Remaining" DecimalDigits="0" UniqueName="Qty_remaining" ReadOnly="true">
                                        <telerik:GridTemplateColumn HeaderText="Number of Containers" UniqueName="Container_cnt" DataField="Container_cnt">   
                                                <telerik:RadNumericTextBox ID="ContainerCnt" runat="server" MinValue="0" MaxValue="999999999"><NumberFormat GroupSeparator="" DecimalDigits="0" /></telerik:RadNumericTextBox>
                                        <telerik:GridTemplateColumn HeaderText="Qty to Receive" UniqueName="Qty_toreceive" DataField="Qty_toreceive">   
                                                <telerik:RadNumericTextBox ID="Qty_toreceive" runat="server" Type="Number"></telerik:RadNumericTextBox>
                                        <telerik:GridTemplateColumn HeaderText="Mfg Lot #" UniqueName="MfgLotNo" DataField="MfgLotNo">   
                                                <telerik:RadTextBox ID="MfgLotNo" runat="server" MaxLength="15"></telerik:RadTextBox>                                           
                                        <telerik:GridTemplateColumn HeaderText="Bin #" UniqueName="Bin_no">
                                                <telerik:RadDropDownList runat="server" ID="Bin_no" AutoPostBack="false" DataTextField="Bin" DataValueField="Bin">
                                <ClientSettings AllowKeyboardNavigation="false" AllowColumnsReorder="false" Selecting-AllowRowSelect="true">
    <telerik:RadButton ID="btnAddSelectedRows" runat="server" Text="Add Selected Rows To Receipt" OnClientClicked="addSelectedRows"
                                ToolTip="Add Selected Rows" AutoPostBack="false">
    <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">
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                            <telerik:AjaxUpdatedControl ControlID="rgPOLines" />
                            <telerik:AjaxUpdatedControl ControlID="rgMfgLot" />
                    <telerik:AjaxSetting AjaxControlID="rgMfgLot">
                            <telerik:AjaxUpdatedControl ControlID="rgMfgLot" />
            <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecorationZoneID="demo"
                DecoratedControls="All" EnableRoundedCorners="false" />

  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 12 Oct 2015 Link to this post

    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.

    Konstantin Dikov
    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
Back to Top