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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to update the data source of a child grid when adding a record?

Thread ID:

Created:

Updated:

Platform:

Replies:

148562 Oct 24,2019 10:48 PM UTC Oct 25,2019 11:21 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: Grid
Itzel Mariana Ramos PEña
Asked On October 24, 2019 10:48 PM UTC

Hi, i'm loading my datasourcce from a viewbag

 DataSource = (IEnumerable<object>)ViewBag.DataSource,
                                   QueryString = "test",
                                   ShowColumnMenu = true,

when i add a record i want to update, i am assigning it an id to be able to update it but it doesn't respect it 

 Columns = new List<Syncfusion.EJ2.Grids.GridColumn>
                                              {
                                                  new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", IsPrimaryKey=true, Width=""} ,
                                                 // new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                  new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                  //new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                  new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                  new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                  new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                  //new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                  new Syncfusion.EJ2.Grids.GridColumn(){ Field="", HeaderText="", Width=""} ,
                                                 
                                              
                                                  new Syncfusion.EJ2.Grids.GridColumn(){HeaderText="Agregar ", Template="#btnTemplate"}
                                       },Id="SegundoNivel",

this is my function to update and reload the view bag

function factura(e) {
            console.log("Bloque-"+ e);
            $.ajax({
                url: "@Url.Action("Add", "Consulta", new {area="Mantenimiento" }, Request.Url.Scheme)",
                data: { id: e },
                success: function (nivel2) {
                    if (nivel2.success) {
                        var grid = document.getElementById("SegundoNivel").ej2_instances[0];
                        console.log(grid);
                        grid.dataSource = nivel2.nivel2
                    } else {
                        swal.fire({
                            title: "Operacion incorrecta",
                            text: nivel2.responseText,
                            type: "error"
                        })
                    }
                }
               
            })

        }


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On October 25, 2019 11:21 AM UTC

Hi Itzel, 

Thanks for contacting Syncfusion support. 

Before providing solution, could you please share more or below details about your requirement that will helpful for us to analyze further at our end. 

  • By default, while assigning viewbag as data source for grid then it considered as a local data so all grid actions(CRUD, page etc.,) performed locally.
  • We have editing option in grid so you can use editSettings to perform CRUD action in grid.
  • Do you want to update parent data based on child grid data source?
  • Share the exact scenario or video to demonstrate your query and full code example to validate further



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon