Fire Insert Command with Arguments using Jquery on Hierarchical grid

10 posts, 0 answers
  1. Meera
    Meera avatar
    14 posts
    Member since:
    Mar 2012

    Posted 02 Oct 2012 Link to this post

    Hi, 
     
    Is it possible to send insert command in hierarchical grid using a java script? 
    I need to pass argument from client side and also refresh the selected parent/child grid.

    Some thing like the delete command :
    NGgridTableView.deleteItem(NGgriditemIndexHierarchical);

    This is the kind of grid i  am  referring to  and i am binding the grid with data table 'On-Need-DataSource' event.
    http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx

    I would really appreciate any suggestions.

    Thanks
    Meera
  2. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 04 Oct 2012 Link to this post

    Hello Meera,

    You could fire an InitInsert command with your corresponding GridTableView as demonstrated in the following demo:
     http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-firecommand.html

    I hope this will prove helpful.

    All the best,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Meera
    Meera avatar
    14 posts
    Member since:
    Mar 2012

    Posted 05 Oct 2012 Link to this post

    Hi,

    Thank you for your reply.

    Could you give me an example with the command fireCommand("InitInsert"," ") ? I would like to pass column name and values as arguments and is it possible to have multiple arguments like fireCommand("InitInsert", "column1 ", "column2", "column3" )

    Thanks,
    Meera

  4. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 08 Oct 2012 Link to this post

    Hi Meera,

    You could use the following approach:
      JavaScript:
    function buttonClicked() {
        var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        var args = "Column1,Column2,Column3";
        masterTable.fireCommand("CustomInsertCommand", args);
    }
      C#:
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "CustomInsertCommand")
        {
            string[] arguments = e.CommandArgument.ToString().Split(',');
            GridCommandItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem;
            commandItem.FireCommandEvent(RadGrid.InitInsertCommandName, String.Empty);
        }
    }

    That should do the trick.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Meera
    Meera avatar
    3 posts
    Member since:
    Jan 2013

    Posted 21 Feb 2013 Link to this post

    After inserting into the hierarchical grid, the grid does not refresh to show the recently inserted item. Is there a way to do it without calling databind or rebind event?
  6. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 26 Feb 2013 Link to this post

    Hello Meera,

    In case you are inserting the new record directly into the database, you will need to rebind the corresponding table view. However, when inserting the record using the implemented PerformInsert functionality of RadGrid, the grid should be refreshed automatically:
    http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx

    Hope this helps.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Meera
    Meera avatar
    3 posts
    Member since:
    Jan 2013

    Posted 28 Feb 2013 Link to this post

    Hi,
    I would like to fire RadGrid.PerformInsertCommandName using javascript and update the grid. The behavior i need is exactly like the RadGrid.deleteItem and want to pass arguments from client side.

    Thanks,
    Meera
  8. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 05 Mar 2013 Link to this post

    Hello Meera,

    You can fire a PerformInsert command to an already opened Insert form:
    http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-firecommand.html

    However, in order to insert a record on a single click, you will need to insert the item directly to your datasource manually and then call rebind to the corresponding GridTableView:
    http://www.telerik.com/help/aspnet-ajax/grid-insert-update-delete-at-database-level.html

    I hope the clarification was helpful.

    All the best,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  9. Prava kafle
    Prava kafle avatar
    217 posts
    Member since:
    Apr 2010

    Posted 29 Oct 2018 Link to this post

    Hi Eyup ,

    Perform Insert only works if there is atleast one record in a grid. If you are trying to add 1st record using this command, it does not  cause any postback. How do I use this command to enter 1st record in an empty table?

     

    Thanks,

    Prava

  10. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 01 Nov 2018 Link to this post

    Hi Prava,

    This behavior is explained in the following article:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/gridtableview-object/methods/firecommand

    You can initiate the insert mode from server-side. There are various options to achieve that: using the InsertItem() method, setting the IsItemInserted to true and then rebinding the grid or using the FireCommandEvent method.

    Now, the question remaining is as follows: how can I initiate an action from client-side to go to server. There is the standard ways of course like doPostBack, but you can also use the ajaxRequest method to achieve this requirement:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/server-side-programming/events/onajaxrequest

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top