Hi,
I would like to have a button on toolbar in grid and then by clicking on the button the pup up appears. Then It provides opportunity to add new raw in the grid (insert information in sql server). I am not sure which ways are better, using 1.toolbar.Create() or 2.toolbar.custom()?
1. if I use toolbar.Create().Text("default add"), I have Create(create => create.Action("AddNewSample", "MyController", new { model = "#=MyModel#" })) in DataSource.
Then, I have the popup, but I don't know how I can add information through Update button. It seems it does not call the function in controller.
here is my controller:
public ActionResult AddNewSample(long? A, string B, string C, DateTime D)
{
if (ModelState.IsValid)
{
db.Sp_Sample_Ins(A, B, C, D);
}
return View("Index");
}
2. But If I use toolbar.Custom(), I should create pop up window myself. so I have toolbar.Custom().Text("Add New Sample").HtmlAttributes(new { id = "customCommand" });
and in JavaScript I tried to follow this:
http://demos.telerik.com/aspnet-mvc/grid/custom-command
Preferably, I would like to have a template in another page(not on my Grid's page).
but I dose not work.
I appreciate any suggestion and help.
6 Answers, 1 is accepted
The first approach is preferred as it is the built-in supported one:
http://demos.telerik.com/aspnet-mvc/grid/editing-popup
Once the button is clicked the Controller should be called if there is no error in the console.
Could you provide the dataSource configuration, so we can inspect it?
Also, please check the network tab to inspect if the Grid is making any requests when the update button is clicked.
If the issue still occurs, please provide a runnable example and I will gladly investigate further.
Regards,
Stefan
Progress Telerik

Thank you Stefan. Your hints helped me to figure out the problem. Actually, I did not pass the correct route value to my controller, by changing the route value the problem is solved.
Now, I have two more questions for you.
First, Whether the project is able to insert data into SQL server or not, I can see the new row in the Grid. How Can I prevent that not to happen?
Second, How can I customize the pop-up window? for instance I want to have "datepicker" for the birth date and checkbox for some fields in pop-up.
Regarding the questions:
1) The new row is added visually when the Add new record button is clicked without making a request to the server and the server to the database. Then when the changes are saved, the record will be visible if the Grid receives success for the create operation.
2) The popup can be set to a custom template, where all of the fields are customizable as well as the layout. I runnable example can be found here:
http://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/editing/custom-popup-editor
Also, please have in mind that the Grid will automatically show DatePicker for all DateTime fields and checkboxes for all Boolean fields.
Also, please have in mind that we will appreciate if a separate ticket(forum post) is submitted when the new question is not directly related to the first one, as this is helping us to determine which scenarios are most commonly used and based on that to improve the documentation in that direction.
Stefan
Progress Telerik


I'm glad to hear that the second issue is resolved.
If additional assistance is needed for the first one, please provide a runnable example demonstrating the scenario, or submit a new ticket for the isolated issue.
Regards,
Stefan
Progress Telerik