Pass a hidden jqGrid value when editing on ASP.Net MVC


Pass a hidden jqGrid value when editing on ASP.Net MVC



I have a jqGrid in an ASP.Net MVC.

The grid is defined as:

$("#list").jqGrid({     url: '<%= Url.Action("History", "Farrier", new { id = ViewData["horseId"]}) %>',             editurl: '/Farrier/Add',             datatype: 'json',             mtype: 'GET',             colNames: ['horseId', 'date', 'notes'],             colModel: [           { name: 'horseId', index: 'horseId', width: 250, align: 'left', editable:false, editrules: {edithidden: true}, hidden: true },           { name: 'date', index: 'farrierDate', width: 250, align: 'left', editable:true },           { name: 'notes', index: 'farrierNotes', width: 100, align: 'left', editable: true }           ],             pager: jQuery('#pager'),             rowNum: 5,             rowList: [5, 10, 20, 50],             sortname: 'farrierDate',             sortorder: "DESC",             viewrecords: true         }); 

What I want to be able to do, add a row to the grid, where the horseId is either a) not displayed or b) greyed out. But is passed to the controller when saving.

The way it's set up is this grid will only have 1 horse id at a time (it will exist on a horse's property page.)

The only time I've gotten anything to work is when I made it editable, but then that opens it up for the user to modify the id, which isn't a good idea.

So is there some way I can set this value before submitting the data? it does exist as a variable on this page, if that helps any (and I've checked that it isn't null).

Thanks


Update dropdown values

1:

Good/Simple shopping cart example using asp.net mvc and jquery
I ended up defining a jscript variable with a ViewData value. How can we pass class instances to view? Then used this for the editoption: defaultvalue property.. How can I hide ActionLinks based on user roles? Here's my script:. Code generation for views broken when using custom MVC ViewData classes
var defVal = '<%= ViewData["horseId"] %>';     $(function() {         $("#list").jqGrid({             url: '<%= Url.Action("History", "Farrier", new { id = ViewData["horseId"]}) %>',             editurl: '/Farrier/Add',             datatype: 'json',             mtype: 'GET',             colNames: ['horseId', 'date', 'notes'],             colModel: [           { name: 'horseId', index: 'horseId', width: 250, align: 'left', editable: true, editoptions: { defaultValue:defVal}, hidden:true },           { name: 'date', index: 'farrierDate', width: 100, align: 'left', formatter:'date', datefmt: 'mm/dd/yyyy', editable: true,  editrules: {date:true} },           { name: 'notes', index: 'farrierNotes', width: 500, align: 'left', editable: true, edittype: 'textarea' }           ],             pager: jQuery('#pager'),             rowNum: 5,             rowList: [5, 10, 20, 50],             sortname: 'farrierDate',             sortorder: "DESC",             viewrecords: true,             width: 850         });         jQuery("#list").navGrid('#pager', { add: true });     }); 
I need a language dictionary

79 out of 100 based on 74 user ratings 189 reviews

*