We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Selected grid details add to another grid

Thread ID:

Created:

Updated:

Platform:

Replies:

128556 Jan 28,2017 10:42 PM Feb 16,2017 07:58 AM ASP.NET Web Forms 12
loading
Tags: Grid
Pratheep
Asked On January 28, 2017 10:42 PM

Hi

If I click product grid button (select button) ,selected product details  can add  to material grid ?


Thanks
Pratheep

Attachment: WebApplication1_427ce8c2.rar

Mani Sankar Durai [Syncfusion]
Replied On January 30, 2017 01:55 AM

Hi Pratheep, 

Thanks for contacting Syncfusion support. 

We have analyzed your provided sample and based on your requirement we have modified your sample that can be downloaded from the below link. 
Please refer the below code example. 
<ej:Grid ID="ProductGrid" ClientIDMode="Static" runat="server" AllowPaging="True" AllowFiltering="false" OnServerEditRow="EditEvents_ServerEditRow" 
                    OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow"> 
                  
                    <ClientSideEvents ActionComplete="complete" RowSelected="selected" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" /> 
... 
 
<script type="text/javascript"> 
 
    ... 
 
       function selected(args) { 
           var data = $('#<%= ProductGrid.ClientID %>').ejGrid("instance")._dataSource(); 
           var grid = $('#<%= ProductGrid.ClientID %>').ejGrid("instance"); 
           var record = args.data.Productcode; 
           var detaildata = ej.DataManager(data).executeLocal(ej.Query().where("Productcode", ej.FilterOperators.equal, record, false)); 
           var gridObj = $('#<%= MaterialGrid.ClientID %>').ejGrid("instance"); 
           gridObj.dataSource(ej.DataManager(detaildata)); 
       } 
 
</script> 

From the above code example we have used RowSelected event in grid to bind the selected data for the MaterialGrid. 

Refer the documentation link. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Pratheep
Replied On January 31, 2017 02:50 AM

Hi Manisankar Durai.

Thank you for your support.Working fine

Thanks
Pratheep

Mani Sankar Durai [Syncfusion]
Replied On January 31, 2017 11:14 PM

Hi Pratheep, 

We are happy to hear that your problem has been solved. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Pratheep
Replied On January 31, 2017 11:46 PM

Hi

last selected product code only showing  MaterialGrid.earlier selected codes not showing

example 

product code
0001
0002
0003

if I select 0001 that will appear at 
Material Grid after that I select 0002 than 0002 only showing at MaterialGrid
Can I get all select product codes show at
Material Grid (0001,0002)


 It's possible  without select ProductGrid row , client side button (Product Grid button ) click event  add  product code to MaterialGrid 

  <ej:Column HeaderText=" " Template="true" TemplateID="#buttonTemplate" TextAlign="Center" Width="75" AllowFiltering="false"/> 

      $(function () {

 

           $(".Details").ejButton({

 

               click: function (e) {

 

                         

                          

               },

           });

       }


Thanks
Pratheep




Mani Sankar Durai [Syncfusion]
Replied On February 2, 2017 06:18 AM

Hi Pratheep, 

Based on your requirement we have prepared a sample that can be downloaded from the below link. 
In this sample we have passed the selected data to the MaterialGrid dataSource only when clicking the select button of ProductGrid. Using dataSource property we have pushed the selected records in MaterialGrid. 
Please refer the below code example, 
$(function () { 
           $(".Details").ejButton({ 
                click: function (e) { 
                    var obj = $('#<%= ProductGrid.ClientID %>').data("ejGrid"); 
                    var record = obj.getSelectedRecords(); 
                    var gridObj = $('#<%= MaterialGrid.ClientID %>').ejGrid("instance"); 
                   if (gridObj.model.dataSource == null) 
                       gridObj.dataSource(record); 
                   else { 
                       gridObj.model.dataSource.push(record[0]);   //push the dataSource object to the grid. 
                       gridObj.refreshContent(); 
                   } 
}) 

Refer the documentation link. 

Please let us know if you need further assistance 

Regards, 
Manisankar Durai. 


Pratheep
Replied On February 8, 2017 12:45 PM

HI Manisankar Durai.

Thank you for your help.Its working fine

Thanks
Pratheep

Mani Sankar Durai [Syncfusion]
Replied On February 8, 2017 11:04 PM

Hi Pratheep, 

We are happy to hear that your problem has been solved. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Pratheep
Replied On February 13, 2017 08:33 AM

Hi

Product Grid   unable to update  Type  / delete the records

after product details  add  to material grid unable to update material  code, material  name / delete the material records

Thanks

Pratheep



Attachment: WebApplication1_68d1d438.rar

Pratheep
Replied On February 13, 2017 09:33 AM

Product Grid   after  update  Type  / delete the records  select button not working

after product details  add  to material grid unable to update material  code, material  name / delete the material records

Thanks

Pratheep

Attachment: WebApplication1_fc7ccd17.rar

Mani Sankar Durai [Syncfusion]
Replied On February 14, 2017 08:07 AM

Hi Pratheep, 

Query 1: Product Grid   after update Type / delete the records select button not working  
  We have analyzed your query and we suggest you to render the button inside the dataBound event of grid. Since after performing server side delete operation the template button is rendered into normal button. So upon clicking the button it didn’t fire the click event in ejButton.   
Please refer the below code example 
      <ej:Grid ID="ProductGrid" ClientIDMode="Static" runat="server" AllowPaging="True" AllowFiltering="false" OnServerEditRow="EditEvents_ServerEditRow" 
                    OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow"> 
                  
                    <ClientSideEvents ActionComplete="complete"  EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit"  DataBound="databound" /> 
 
                     ... 
 
 
       function databound(args){ 
           $(".Details").ejButton({ 
                click: function (e) { 
                    ... 
               } 
             }); 
  } 


Query 2: after product details add to material grid unable to update material code, material name / delete the material records 
 
From your sample we found that you are using the name attribute as Productcode and productname in material grid dialog template. So that when editing the value it just update the value for Productcode and Producename instead of MaterialCode and Materialname. 
Refer the below code example. 
<script type="text/template" id="materialtemplate"> 
... 
                    <input id="Materialcode" name="Materialcode" value="{{: Materialcode}}"  
... 
                    <input id="Materialname" name="Materialname" value="{{:Materialname}}" class="e-field e-ejinputtext valid" 
... 
        </table> 
    </script> 
  
Also in server side you are trying to update the product grid details using session variable in Material grid server side edit operations. Instead that we suggest you to set the updated values from client to server side in session variable and use that session variable for server side CRUD operations. So that we can update the values for Material grid. 
Refer the below code example. 
 
        protected void EditActionMaterial(string eventType, object record) 
        { 
 
            List<Materials> data = Session["MaterialDataSource"] as List<Materials>; //update the material grid records after selecting from client side. 
            Dictionary<string, object> KeyVal = record as Dictionary<string, object>; 
 
            if (eventType == "endEdit") 
            { 
                Materials value = new Materials(); 
                foreach (KeyValuePair<string, object> keyval in KeyVal) 
                { 
 
                    if (keyval.Key == "Materialcode") 
                    { 
                         
                   ... 
 
                    } 
                } 
            } 
            Session["MaterialDataSource"] = data; 
            this.MaterialGrid.DataSource = data; 
            this.MaterialGrid.DataBind(); 
 
        } 
 
 
 
 
 
        [Serializable] 
        public class Materials 
        { 
            public Materials() 
            { 
 
            } 
            public Materials(int Materialcode, string Materialname, int Productcode, string Productname) 
            { 
                this.Materialcode = Materialcode; 
                this.Materialname = Materialname; 
                this.Productname = Productname; 
                this.Productcode = Productcode; 
            } 
            public int Materialcode { get; set; } 
            public string Materialname { get; set; } 
            public int Productcode { get; set; } 
            public string Productname { get; set; } 
 
        } 
 
Please let us know if you need further assistance. 
 
Regards, 
Manisankar Durai. 


Pratheep
Replied On February 15, 2017 04:26 AM

Hi Manisankar Durai.

Thank you for your support

Cant update Material Grid


List<Materials> data = Session["MaterialDataSource"] as List<Materials>;

// empty selected Product code


 

 

            if (eventType == "endEdit")

            {

                Materials value = new Materials();

                foreach (KeyValuePair<string, object> keyval in KeyVal)

                {

 

                    if (keyval.Key == "Productcode")

                    {

                        value = data.Where(d => d.Productcode == (int)keyval.Value).FirstOrDefault();

                        value.Productcode = Convert.ToInt32(keyval.Value);

                    }

                    else if (keyval.Key == "Materialname")

                        value.Materialname = Convert.ToString(keyval.Value);

                    else if (keyval.Key == "Materialcode")

                        value.Materialcode = Convert.ToInt16(keyval.Value);

 

 

                }




Thanks
Pratheep



Attachment: WebApplication1_3d6aeed8.rar

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On February 16, 2017 07:58 AM

Hi Pratheep,  
 
We suggest to assign the convert the Selected records to string and assign them to Hidden element. Later, in the Edit action of the Grid, get the records bound to the child Grid. Refer to the following code example.  
 
<asp:HiddenField ID="SelectRecords" ClientIDMode="Static" runat="server" /> 
 
 
   <script type="text/javascript"> 
 
      
 
       function OnCreate(args) { 
 
 
           $(".Details").ejButton({ 
 
               click: function (e) { 
 
                  var obj = $('#<%= ProductGrid.ClientID %>').data("ejGrid"); 
                   var record = obj.getSelectedRecords(); 
                   var gridObj = $('#<%= MaterialGrid.ClientID %>').ejGrid("instance"); 
                   $("#SelectRecords").val(JSON.stringify(record)); 
                    if (gridObj.model.dataSource == null) 
                        gridObj.dataSource(record); 
                    else { 
                        gridObj.model.dataSource.push(record[0]); 
                        gridObj.refreshContent(); 
                    } 
 
                } 
 
            }); 
            } 
 
</script> 
 
 
       protected void EditActionMaterial(string eventType, object record) 
        { 
 
            JavaScriptSerializer ser = new JavaScriptSerializer(); 
            //get currentView 
            List<Materials> sel = ser.Deserialize<List<Materials>>(this.SelectRecords.Value); 
             . . . 
                 .. . 
            Session["MaterialDataSource"] = data; 
            this.MaterialGrid.DataSource = data; 
            this.MaterialGrid.DataBind(); 
 
        } 
 
We have modified the sample that can be downloaded from the following location. 
 
 
Regards, 
Seeni Sakthi Kumar S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;