Home>

javascript code:

ext.onready (function () {
var sm=new ext.grid.checkboxselectionmodel ();
var cm=new ext.grid.columnmodel ([
  new ext.grid.rownumberer (),  sm,    {header:"number", dataindex:"id", sortable:true},    {header:"name", dataindex:"name", sortable:true},    {header:"Gender", dataindex:"sex", sortable:true, renderer:function (value) {
    if (value == "male") {
     return "<span>Red Boy</span><img src =" ./img/125.gif ">";
    } else {
     return "<span>green girl</span><img src =" ./img/123.gif ">";
    }
    }},    {header:"description", dataindex:"descn", sortable:true}
  ]);
  cm.defaultsortable=true;
  var ds=new ext.data.store ({
    proxy:new ext.data.httpproxy ({url:"page.jsp"}),    reader:new ext.data.jsonreader ({
        totalproperty:"totalproperty",        root:"root"
  },  [
    {name:"id", mapping:"id"},    {name:"name", mapping:"name"},    {name:"sex", mapping:"sex"},    {name:"descn", mapping:"descn"}
  ]),  remotesort:true
  });
  var grid=new ext.grid.gridpanel ({
  el:"grid",  title:"ext grid test",  width:450,  height:410,  trackmouseover:false,  loadmask:{msg:"Loading data,Please wait ... "},  store:ds,  cm:cm,  sm:sm,  bbar:new ext.pagingtoolbar ({
      pagesize:5,      store:ds,      displayinfo:true,      displaymsg:"Currently displaying {0}-{1} records of {2} records",      emptymsg:"no topics to display"
    })
  });
  grid.render ();
  ds.load ((params:{start:0, limit:5}));
});

jsp code:

<%@page language="java" pageencoding="utf-8"%>
<%
string start=request.getparameter ("start");
string limit=request.getparameter ("limit");
int index=integer.parseint (start);
int pagesize=integer.parseint (limit);
string json="{totalproperty:100, root:[";
string sex="";
for (int i=index;i<pagesize + index;i ++) {
if (i%2 == 0)
{
  sex="male";
}
else {
  sex="female";
}
  json +="{id:" + i + ", name:" "+ i +" ", sex:" "+ sex +" ", descn:" descn "+ i
  + ""} ";
  if (i!=pagesize + index-1) {
  json +=",";
  }
}
json +="]}";
response.getwriter (). write (json);
system.out.print (json);
%>
jsp
  • Previous Smarty advanced application cache operation skills analysis
  • Next PHP simple way to achieve infinite classification