Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






2 Questions about jqGrid (Subgrid) and json(string)

No Tags
UserPost

10:08
11/08/2009


Arne

Guest

Hi everybody


I'm developping a web application with Java, Springframework, DWR and JQuery.

My first grid was successful.

$("#sortable").jqGrid({
   datatype: 'jsonstring',
   userdata: mydata,
   colNames:[
     '<spring:message code="label"/>',
     '<spring:message code="label"/>'
   ],
   colModel:[
     { name:'field1', index:'field1', sortable:true, sorttype:'int' },
     { name:'field2', index:'field2', sortable:false }
   ],
   emptyrecords: "<spring:message code="label"/>",
   hoverrows: true,
   toolbar: [true, "bottom"],
   width: 653,
   height: 300
});

var mydata = [
   <c:forEach var="item" items="${listAsJson}" varStatus="status">
     <c:choose>
       <c:when test="${status.last}">
         ${item}
       </c:when>
       <c:otherwise>
         ${item},
       </c:otherwise>
     </c:choose>
  </c:forEach>
];

for(var i=0;i<=mydata.length;i++) {
  $("#sortable").addRowData(i+1,mydata[i]);
}

But now I need some sub grids.

The problem is, that I don't know, how to add the rows into the sub grid. I still have all datas in the response (I'm looking for the datas in the previous Spring-Controller and add them into the request).


The second question is about json. I have objects in objects. The json string looks ok, or doesn't it?

{ "name": "test", "phone": "111″,  "address": { "street": "street" } }

But if I change the ColModel to:


colModel:[
  { name:'address.street', index:'address.street' }
],

I don't get any results.


It makes me … :S


Best regards

Arne


01:53
13/08/2009


tony

Sofia, Bulgaria

Moderator

posts 7392

Hello,

http://www.trirand.com/jqgridw…..id#methods


One note (which I will correct into the docs)

If you use subGridJson you should use the method this way:

var mygrid = jQuery("#mygrid")[0];

mygrid.subGridJson(arraydata,rowid)

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

01:56
13/08/2009


tony

Sofia, Bulgaria

Moderator

posts 7392

Hello,

About the second question.

The addRowData currently does not support this. I suggest you to use datatype as function – see docs and addJSONData method to add data. This method support this named convention.

Regards

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

No Tags

About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

215


Currently Online:

70 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 10279

Posts: 30383

Membership:

There are 11049 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1210

markw65 – 179

kobruleht – 144

phicarre – 132

YamilBracho – 124

Renso – 118

Administrators: admin (60 Posts)

Moderators: tony (7392 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information