Hi Team,
I am using an iggrid and I am unable to pass any data from view to the controller in ajax call . Below is my code
Javascript code
$("#csagrid").igGrid({ columns: [
{ headerText: "Manager", key: "EMPLOYEE_NAME", dataType: "string" }, { headerText: "CSA", key: "CSA_NB", dataType: "string" }, { headerText: "Entry Date", key: "ENTRY_DATE", dataType: "date" }, { headerText: "Project Name", key: "PROJECT_NAME", dataType: "string" }
], defaultColumnWidth: "200px",
width: "100%", showHeaders: true, fixedHeaders: false, type: "POST", caption: "Report", dataSourceType: "json", dataSource: "/Reports/CSAReportData/", data: { year: "0017" } });
Controller code
public JsonResult CSAReportData(string year) { return jsonResult; }
Although I am passing "0017" in year parameter but unable to get it in the controller code . I am getting null in controller .
Create a class containing year: string property and expect object of this type in the controller:
public class DateYear {
public year: string {get; set;}
}
public JsonResult CSAReportData(DateYear date){return jsonResult;}
I have already passed "0017" value in year property in javascript code and its a string type, wanted to get this data in my controller code .
Hello Tapas,
I am glad that you find my suggestion helpful.
Thank you for using Infragistics components.
Best Regards,
Martin Dragnev,
Infragistics
Ok.So, the grid can not pass any data . In that case, I will send an ajax request.
Thanks for your help
You should create ajax request by yourself.
The grid can not send the request by itself, so depends on when you want to send the data you should bind to the specific event.
If you have any additional questions or concerns could you please provide me with more information about what you desire to do, what data you want to sent (grid data for example), what should invoke the request and etc.
Javascript code:
$(function () {
$("#grid").igGrid({ columns: [
{ headerText: "ABD Manager", key: "ABDManager", dataType: "string" }, { headerText: "CSA #", key: "CSA", dataType: "string" }, { headerText: "Entry Date", key: "EntryDate", dataType: "date" }, { headerText: "Project Name", key: "Name", dataType: "string" }, { headerText: "Status Code", key: "Status", dataType: "string" }
width: "100%", showHeaders: true, fixedHeaders: false, requestType: "POST", dataSourceType: "json", dataSource: "/Reports/CSAReportData/", data: { year: "0017" }
}); });
controller code (ReportsController):
In the above method, year is coming null ,instead of 0017 which I am passing from the javascript .I tried with requestType as well but its not working . I want to pass year data from javascript to controller .
Which version of the product do you use?
Could you please try replacing igGrid property: type:"POST" with requestType : "POST".
Also, if your issue still occurs can you isolate it in basic sample and attach it so that I can observe what exactly is happening?