This is a migrated thread and some comments may be shown as answers.

Toolbar.Create or Toolbar.Custom - grid mvc

6 Answers 705 Views
Grid
This is a migrated thread and some comments may be shown as answers.
haleh
Top achievements
Rank 1
haleh asked on 25 Sep 2017, 08:52 AM

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

Sort by
0
Accepted
Stefan
Telerik team
answered on 27 Sep 2017, 06:34 AM
Hello, Amin,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
haleh
Top achievements
Rank 1
answered on 27 Sep 2017, 01:59 PM

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.

 

 

0
Accepted
Stefan
Telerik team
answered on 29 Sep 2017, 06:23 AM
Hello, Amin,

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.
 
Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
haleh
Top achievements
Rank 1
answered on 02 Oct 2017, 06:02 AM
Thank you very much Stefan. My second problem is solved.
0
haleh
Top achievements
Rank 1
answered on 02 Oct 2017, 06:02 AM
Thank you very much Stefan. My second problem is solved.
0
Stefan
Telerik team
answered on 03 Oct 2017, 05:54 AM
Hello, Amin,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
haleh
Top achievements
Rank 1
Answers by
Stefan
Telerik team
haleh
Top achievements
Rank 1
Share this question
or