I have used the jqGrid using the standard jsson plugin, using the exclude elements for excluding all the other action properties, and it works correctly. I thing the js that constructs the grid lacks the json mapper. Tomorrow morning I will send you the code I use for this.
Si quieres ser más positivo, pierde un electrón Miguel Ruiz Velasco S. On Mon, Sep 29, 2008 at 16:50, Francisco Exposito <[EMAIL PROTECTED]> wrote: > > I am trying to do it by hand. > > I have this in my jsp: > > <script type="text/javascript"> > jQuery(document).ready(function() > { > jQuery("#list1").jqGrid({ > url:'/WebAds/AjaxRetrieveUser.do', // this is the page where the XML Output > is delivered > datatype: "json", > colNames:['Nombre','Desc'], > colModel:[ > {name:'name',index:'name', width:20}, > {name:'description',index:'description', width:20} > ], > rowNum:10, > rowList:[10,20,30], > imgpath: 'themes/sand/images', > pager: jQuery('#pager1'), > sortname: 'id', > viewrecords: true, > sortorder: "desc", > width: 620, // new width > height: 220, > rowheight: 10, // newrow height > caption: "Table Caption" > }); > }); > jQuery("#list1").navGrid('#pager1',{edit:false,add:false,del:false,refresh:true,searchtext:"Suchen"}); > > > </script> > > > The AjaxRetrieveUser.do is defined in struts.xml as: > > <action name="AjaxRetrieveUser" class="ads.web.action.RetrieveUser"> > <result type="customJSON"/> > </action> > > and my execute function from customJSON is: > > List<Color> colors = new ArrayList<Color>(); > Color c1 = new Color(); > c1.setId(1); > c1.setName("n1"); > c1.setDescription("d1"); > > Color c2 = new Color(); > c2.setId(2); > c2.setName("n2"); > c2.setDescription("d2"); > > colors.add(c1); > colors.add(c2); > > JQGridJSONModel json = new JQGridJSONModel(); > json.setPage("1"); > json.setRecords(colors.size()); > json.setTotal("1"); > > List<JQGridRow> rows = new ArrayList<JQGridRow>(); > > for (Color c : colors) { > JQGridRow row = new JQGridRow(); > row.setId(c.getId()); > List<String> cells = new ArrayList<String>(); > cells.add(c.getName()); > cells.add(c.getDescription()); > row.setCell(cells); > rows.add(row); > } > > json.setRows(rows); > > JSONSerializer serializer = new JSONSerializer(); > String jsonResult = serializer.exclude("*.class").deepSerialize(json); > System.out.println("Resultado = " + jsonResult); > > > which returns: > > {"page":"1","records":2,"rows":[{"cell":["n1","d1"],"id":1},{"cell":["n2","d2"],"id":2}],"total":"1"} > > and it is a JSON string used by jqGrid, as I've read. > > But I receive an error in the console error: > > Error: element is not found > input file: > http://localhost:8080/WebAds/AjaxRetrieveUser.do?page=1&rows=10&sidx=id&sord=desc&nd=1222724640660&_search=false > Line: 1 > > > > > >> To: user@struts.apache.org >> From: [EMAIL PROTECTED] >> Subject: Re: Struts2 + jqGrid possible? >> Date: Mon, 29 Sep 2008 16:22:00 -0400 >> >> Francisco Exposito wrote: >> > Hi, >> > >> > Is it possible to use jqGrid with struts2? I am trying to use it but I >> > don't know how to do it. >> > >> > In the script we have: >> > >> > jQuery("#list2").jqGrid({ >> > url:'server.php?q=2', >> > datatype: "json", >> > colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], >> > .... >> > .... >> > >> > but what about the url? It seems that it will be the data which must be >> > shown in the table, but if I create an action in struts.xml file like >> > that, nothing happens. >> > >> > The class is executed, but no info is shown inside the table. >> >> Your approach is right. I can only assume the response you are >> generating in your action is incorrect. Are you using the JSON plugin to >> write the response, or constructing the JSON by hand? >> >> L. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> > > _________________________________________________________________ > Prueba los prototipos de los últimos en MSN Motor > http://motor.es.msn.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]