1

I am using a jqgrid with a column named 'Comments'. My controller code returns data as follows:


var jsonData = new
{
rows=
....
....
   select new
             {
             col1....
             col2....
             Comments = _Model.GetComments(id),
             })

.......
.....
   return Json(jsonData, JsonRequestBehavior.AllowGet);
}


_Model.GetComments(id) will return a ClientComments Object which has a few properties say CommentID, FirstName, MiddleName etc., which will be bound to each row in the grid

Now in my jqgrid I need to build a tool tip based on Comments column properties and for that I need to use the properties of my Comments in JQGrid for each row. May I know How I can manipulate Comment's properties for each row? Any help would be appreciated.

I tried in my javascript that for each row rowObject.Comments.FirstName and it did not work.

1 Answer 1

2

For the JavaScript version of the grid you would use getDataIDs to get the ID of each row, and then use getRowData to read the data at that row. For example:

var ids = $("#grid").getDataIDs();
for(var i=0; i<ids.length;i++){
   var rowdata = $("#grid").getRowData(ids[i]);

   // Build tooltip here using rowdata.FirstName, rowdata.MiddleName, etc.
}

But, are you working with the JavaScript version of jqGrid or jqGrid ASP.NET component?

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Justin, THanks for ur help again. I missed a very basic point that some comments might be null. So in my javascript i should first check if(rowObject.Comments != null. Only then I can access rowObject.Comments.whateverproperties in that object. So it works fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.