This is a migrated thread and some comments may be shown as answers.
Fire Insert Command with Arguments using Jquery on Hierarchical grid
9 Answers 84 Views
This is a migrated thread and some comments may be shown as answers.
Meera
Top achievements
Rank 1
Meera asked on 02 Oct 2012, 06:34 PM
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

9 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Oct 2012, 03:30 PM
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.
0
Meera
Top achievements
Rank 1
answered on 05 Oct 2012, 12:34 PM
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

0
Eyup
Telerik team
answered on 08 Oct 2012, 03:43 PM
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.
0
Meera
Top achievements
Rank 1
answered on 21 Feb 2013, 01:48 PM
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?
0
Eyup
Telerik team
answered on 26 Feb 2013, 08:23 AM
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.
0
Meera
Top achievements
Rank 1
answered on 28 Feb 2013, 09:17 PM
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
0
Eyup
Telerik team
answered on 05 Mar 2013, 01:42 PM
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.
0
Prava kafle
Top achievements
Rank 1
answered on 29 Oct 2018, 09:15 PM

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

0
Eyup
Telerik team
answered on 01 Nov 2018, 12:41 PM
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.
Tags
Grid
Asked by
Meera
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Meera
Top achievements
Rank 1
Meera
Top achievements
Rank 1
Prava kafle
Top achievements
Rank 1
Share this question
or