I am using jqGrid and my backend is asp.net-mvc. I want to figure out if I can have a different value to read and write a property with my backend.
The background here is that my server side sorting is generic and works by taking the column Name passed in my jqGrid and looks to sort by that property of the object my collection. This works great except for one situation
Lets say i have a grid that shows people data. I have a collection of Person objects on the server. Lets say I have a column that shows personName.
On the client side colModel i set the Name and Index properties of the colModel to be "PersonName".
On the serverside my person object has a PersonName property so when i filter or sort it uses C# reflection to sort and filter by that property.
The issue is that if i want to edit that property and the edit is a select dropdown where the Id is the PersonId and text is PersonName, when i save I want it to save the Id as the "PersonId" property (not the PersonName" property)
My current solution (which feel hacky) is to have two columns in the grid,
Here is an example (simplified to show the point):
{ name: "PersonName", index: "PersonName", width: 78, editable: false },
{ name: "PersonId", index: "PersonId", width: 78, editable: true, hidden: true, editrules: { edithidden: true, required: true} },
One that is visible and used for sorting and filtering but is NOT editable (Name and Index is PersonName) so it doesn't show up on the edit dialog.
A second column that is hidden (hidden:true) but has edithidden:true so it DOES show up on the edit dialog and is used for writing the value (this would be the PersonId) property.
This works but I wanted to see if there is a more elegant way to solve this issue besides having two different columns that really represent one piece of data.