How to get querystring value to Kendo Grid update method and pass to MVC controller
1 Answer 15 Views
Ron
Top achievements
Rank 1
Ron asked on 08 Jul 2021, 03:55 PM | edited on 08 Jul 2021, 06:06 PM

Hi, I have a kendo grid and need to get a querystring value.  See below code.

 

Browser Url = http://blahblah/blah/36?EvaluationCriteriaGrid-mode=edit&chiefEvalCriteriaId=110

 

UI.cshtml

                                

@(Html.Kendo().Grid(Model.ChiefEvaluationCriteriaList.AsEnumerable())
                        .Name("EvaluationCriteriaGrid")
                        .Columns(columns =>
                        {

                            columns.Bound(p => p.EvaluationCriteriaName);
                            columns.Bound(p => p.MinScore).Width(100).Title("Min Score").Format("{0:0}");
                            columns.Bound(p => p.MaxScoreDisplay).Width(100).Title("Max Score");
                            columns.Command(command => { command.Edit(); }).Width(180).Title("Action");
                        })
                        .CellAction(cell =>
                        {
                            if (cell.Column.Title == "Action")
                            {
                                if (cell.DataItem.EvaluationResultID ==
                                    ServiceProxy.Model.DomainConstants.EVALUATION_RESULT_APPROVED)
                                {
                                    cell.HtmlAttributes["style"] = "display:none;";
                                }
                            }
                        })
                        .Editable(editing => editing.Mode(GridEditMode.InLine))
                        .Pageable()
                        .Sortable()
                        .Scrollable()
                        .DataSource(dataSource => dataSource
                        .Server()
                        .Model(model => model.Id(c => c.ChiefEvaluationCriteriaID))
                        .Read("EvaluationQuestionnaire", "EvaluationCriteria", new { area = "Proposal", Id = Model.SolicitationDetails.SolicitationID })
                        .Update("EditEvaluationCriteria", "EvaluationCriteria", new { area = "Proposal", Id = Model.SolicitationDetails.SolicitationID })

                    )

                )

 

Controller.cs

[HttpPost]

 public ActionResult EditEvaluationCriteria( int Id, int chiefEvalCriteriaId, int maxScoreDisplay, int minScoreDisplay = 0 )
        {

               if (ModelState.IsValid)
                    {
                       Do something
                     }

 

                    return view

        }

 

 

Thank you for the support

 

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 13 Jul 2021, 01:51 PM

Hello Ron,

Thank you for the code snippets and details provided.

Could you please confirm in which Event handler the query string should be sent to an Action Method of the Controller:

For this case, here is the approach that I could recommend:

  1. Handle the proper Event of the Kendo UI Grid.
  2. In the Event handler, get the querystring.
  3. Build and execute an Ajax request for sending the querystring to an Action Method in the Controller.
  4. Receive the querystring.
  5. *For this case, I would recommend dividing the string into parts in the Controller. In another way, you will need a couple of Ajax requests.

I hope this information helps.

 

Kind Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Ron
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or