Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
Add row to to hierarchical grid using api(adding child row to subgrid and add father row)
posted

Hi, i was tryind to do a add row to a hierarchical grid, using the api available.

The problem is that when when i add a root row , and then call savechanges it detects the root row and add it to the database, if i try to add a child row it ig_transactions come empty according to firebug.

if i add a new father row, then add a child row to another father, the ig_transactions comes with a miscellanious info about..

i am using your example of ighierarchicalgrid

i add the add row features to root row and child row..

so in this first image we can see the grid and the grid is load with some info.

grid sample

i then press add new row, and add a root row with some data, then i press the save button that call me the a action defined in UpdateUrl(Url.Action("save"))

the method save is called and the ig_transaction has this value

ig_transactions[{"type":"newrow","tid":"4eb2","row":{"ig_pk":5,"ID":1,"Name":"sasa","IsActive":false},"rowId":5}]

lets try that with 2 root rows

[{"type":"newrow","tid":"4eb2","row":{"ig_pk":5,"ID":1,"Name":"sasa","IsActive":false},"rowId":5},{"type":"newrow","tid":"a14f","row":{"ig_pk":5,"ID":2,"Name":"sasas","IsActive":false},"rowId":5}]

from this lines of ig_transaction we can see that we are creating new rows with some info inside..

but we can also see that ig_pk is 5(infragistis grid primary key is that???)what is the meaning of this vallue 5 and the meaning ig_pk?

but this is not the only problem/doubt that i have...

grid sample 2

the second image i am trying to add a root row, and then i am trying to add a child row to the root row number 2..

if i press save te ig_transacation send this [{"type":"newrow","tid":"d880","row":{"ig_pk":5,"ID":6,"Name":"sasas","IsActive":false},"rowId":5}]

as you can see it only send the information regarding the root row that was added,,,

what is the problem...

in the ig_transactions it should send the info about the 2 rows, the parent and the child row..

the method save is something like this

[ActionName("save")]
        public ActionResult save()
        {
      
           
            GridModel m = new GridModel();

            JsonResult result = new JsonResult();
            Dictionary response = new Dictionary();
            List ListCustomer = new List();

            ViewData["GenerateCompactJSONResponse"] = false;
            List<Transaction> categoryTransactions = m.LoadTransactions(HttpContext.Request.Form["ig_transactions"]);
            foreach (Transaction t in categoryTransactions)
            {
               
            }
            List<Transaction> productTransactions = m.LoadTransactions(HttpContext.Request.Form["ig_transactions"]);
            foreach (Transaction t in productTransactions)
            {
               
            }

            result.Data = response;
            return result;
       
    }

i have uploaded a example project with clients and produtcs..

IgHierarchicalGrid_Model.zip
  • 445
    posted

    after seeing your responses i did some testing...

    so the problem appears if i do batch updates, but if i save the information every time i do a add, delete or update and then call save changes it is now possible...

    it detects if the row is a child row or a father row, depending on the value of the layout...

    but if i do some batch updates change a child row and then change a father row, it only return the change on the father grid...

    one other thing that i though i should try is  grid load on demand...but i will create a new project see what comes up..

    is it possible instead of using the model in a direct way, create a view model with the info that i want?

  • 3595
    posted

    Hello Sergio,

    Thank you for posting in our community!
    To your first question – the “ig_pk” is used for internal indexing of the grid rows which might be needed for igGrid structuring and row arranging. It does not affect the new or updated row data which is entered by the user. If you want to use this for any custom implementation please provide me more details to research the matter further.

    To your second question – this behavior is due to an internal issue. It is already discussed in the following forum thread:

    http://es.infragistics.com/community/forums/p/87818/438636.aspx

    You could also download a sample from it presenting a possible workaround to get the child grid data.

    If you need any further assistance please let me know.

     

  • 5513
    Offline posted

    Hello Sergio,

    Each layout stores a transaction log of its own. When you want to save the changes on the server you have the choice to do it for each layout separately or have the hierarchical grid do it for all of them. Code sample for the latter is:

    $("#grid1").igHierarchicalGrid("saveChanges");

    To do it per layout manually you can use something like:

    $.each($("#grid1").igHierarchicalGrid("allChildren"), function () {

       $(this).igGrid("saveChanges");

    });

    I hope this helps! Please, let me know if you have any other questions!

    Best regards,

    Stamen Stoychev