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

Read querystring from kendo grid not passing to parameter in controller action

5 Answers 812 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bharathi
Top achievements
Rank 2
Bharathi asked on 07 Mar 2014, 09:46 PM
Kendo Grid with url takes to another kendo grid

I'm stuck with reading the querystring value from grid1 url to grid2 controller.. Any help appreciated..

Grid1

Index.cshtml
  columns.Bound(e => e.TCBSTAGE).Width(100).ClientTemplate("<a href='/" + "ControllerName" + "/Index?Batchno=#=BatchNo#'>#=TCBSTAGE#</a>");



Grid2Index.Cshtml

<script>$(function(){
   $("#grid").kendoGrid({
  dataSource: {
    transport: {
      read: {  
         url: "ControllerName2/GetRecords",
         contentType: "application/json",
         type: "POST"
      },
      parameterMap: function (options) {       
        return kendo.stringify(options);
      }
    },
    schema: {
      data: "Data",
      total: "Total"
   
    },
    pageSize: 10,
    serverPaging: true,
    serverFiltering: true,
    serverSorting: true
  },
  groupable: true,
  filterable: true,
  sortable: true,
  pageable: true,
  columns: [
 { field: "BatchNo", title: "BatchNo" },
 { field: "Fiscal_Year ", title: "Fiscal_Year" },
 { field: "Department", title: "Department" }
  ]
});
});</script>


Grid 2 controller.. I need to get the Batchno value here

ControllerName2.cs

  [HttpPost]
        public ActionResult GetRecords(int take, int skip, IEnumerable<Kendo.DynamicLinq.Sort> sort, Kendo.DynamicLinq.Filter filter)
        {
            //Batchno from grid1 url
           I need the querystring id from grid1 here....          }


Any Help appreiciated. Thank you

5 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 11 Mar 2014, 01:52 PM
Hello,

Since the script is used in the view, you can render the sent value in the script in order to send it e.g.
<script>$(function(){
$("#grid").kendoGrid({
  dataSource: {
    transport: {
      read: {  
         url: "ControllerName2/GetRecords",
         contentType: "application/json",
         type: "POST",
         data: {
            BatchNo: @Request["Batchno"]
         }
      },
      ...


Regards,
Daniel
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

0
Bharathi
Top achievements
Rank 2
answered on 11 Mar 2014, 02:12 PM
Hi,

         Thanks for the answer.. but How do i read that BatchNo inside the action.... 

  [HttpPost]
        public ActionResult GetRecords( int take, int skip, IEnumerable<Kendo.DynamicLinq.Sort> sort, Kendo.DynamicLinq.Filter filter, HttpContextBase httpcontext)        
        {
 //read batchno here..
}
0
Bharathi
Top achievements
Rank 2
answered on 11 Mar 2014, 02:50 PM
Thanks It Works...

[HttpPost]
        public ActionResult GetRecords(long BatchNo, int take, int skip, IEnumerable<Kendo.DynamicLinq.Sort> sort, Kendo.DynamicLinq.Filter filter)
        {
         
var bno = BatchNo
.          }
0
Bharathi
Top achievements
Rank 2
answered on 03 Apr 2014, 01:55 PM
@* The DIV where the Kendo grid will be initialized *@
<div id="grid"></div>
 
<script>
 
    $(function () {
        $("#grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                      url: "GetTransctionDetails",
                      contentType: "application/json; charset=utf-8",
                      type: "POST",
                      cache: true,                     
                        data: {
                                Period: @Request["Period"],
                                AccCode: @Request["AccCode"],
                                Fiscalyr: @Request["Fy"],
                                Entity:@Request["entity"]
                              }
                          },
 
                    parameterMap: function (options) {
                      return kendo.stringify(options);
                    }
              },
                schema: {
                    data: "Data",
                    total: "Total"                 
 
                },
                pageSize: 10,
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            groupable: true,
            columnMenu: true,
            filterable: true,
            sortable: true,
            pageable: true,
            columns: [
 { field: "TRANSACTION_KEY", title: "BatchNo", width: "100px" },
 { field: "FISCAL_YEAR ", title: "Fiscal_Year", width: "150px" },
 { field: "ACCOUNTING_PERIOD", title: "Department", width: "150px" }
 
   ]
        });
    });
 
</script>

Hi,

     In the above code the @Request["entity"] is throwing Uncaught Reference Error.... I'm passing string value for the entity... How do you call the parameter with string value... Please find the attached file for more details on the error.. 

Thank you fo 
0
Bharathi
Top achievements
Rank 2
answered on 03 Apr 2014, 02:09 PM
Please Ignore the previous post...

I fixed it .....missed the quotes..

 data: {
                                Period: @Request["Period"],
                                AccCode: @Request["AccCode"],
                                Fiscalyr: @Request["Fy"],
                                Entity:"@Request["entity"]"
                              }
Tags
Grid
Asked by
Bharathi
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Bharathi
Top achievements
Rank 2
Share this question
or