2012-05-14 41 views
1

我想用ajax,jQuery mobile和spring mvc来显示数据库中的数据。jqgrid可以使用jQuery移动吗?

示例:显示表中的课程名称列表。

我现在使用jqgrid来显示数据,但有没有其他的选择,而不使用数据?有很多在论坛上,但大多使用PHP,但我使用弹簧mvc控制器。

请人帮助我..

+3

你可以开始[ “接受”]在你前面的问题(http://meta.stackexchange.com/a/5235/147495)的答案。 – Oleg

回答

0

不知道是否jqGrid的工作与jQuery Mobile的,但对于一个正常的Web应用程序,你可以使用addJSONDatajsonReaderdatatype属性设置为一个功能。下面是一个示例:

function cfgWixGenApplicationsGrid() { 
    var cond = null; 
    $("#tblWixGenApplications").jqGrid({ 
     datatype: function (postdata) { 
      var orderByExpr = ""; 
      if (postdata.sidx != "") { 
       orderByExpr = postdata.sidx + " " + postdata.sord; 
      } 
      getPageList(cond, postdata.page, postdata.rows, orderByExpr, hSuccPageWixGenApplications, hError); 
     }, 
     colNames: ["Id", "Title", "Name", "Version", "MainAssemblyName" 
     ], 
     colModel: [ 
      { name: "Id", index: "Id", width: 50, sorttype: "String", editable: false }, 

      { name: "Title", index: "Title", width: 50, sorttype: "String", editable: true }, 

      { name: "Name", index: "Name", width: 50, sorttype: "String", editable: true }, 

      {name: "Version", index: "Version", width: 50, sorttype: "String", editable: true }, 

      {name: "MainAssemblyName", index: "MainAssemblyName", width: 50, sorttype: "String", editable: true } 
     ], 
     multiselect: false, 
     pager: "#divPagerWixGenApplications", 
     viewrecords: true, 
     jsonReader: { repeatitems: false, root: "rows", page: "page", records: "records", total: "total" }, 
     rowNum: 10, 
     rowList: [10, 20, 30] 
    }); 
} 

getPageList做一个Ajax调用,在我的情况下WCF服务。我想你可以在这里调用MVC网址。

hSuccPageWixGenApplications函数调用addJSONData这样的:

function hSuccPageWixGenApplications(pageData) { 
    var list = []; 
    $.each(pageData.List, function (index, value) { 
     if (!value.IsDeleted) { 
      list.push(value); 
     } 
    }); 
    var grid = $("#tblWixGenApplications")[0]; 
    var pData = new Object(); 
    var recCount = pageData.RecordCount == null ? 1000 : pageData.RecordCount; 
    pData.page = pageData.PageNo; 
    pData.records = recCount; 
    pData.rows = list; 
    pData.total = recCount/pageData.PageSize; 
    grid.addJSONData(pData); 
}; 
+0

但我需要做一个移动应用程序..这就是为什么我使用jquerymobile ..我读了一些他们说jqgrid可以在手机中使用,但大多数使用php的例子.. – sone

相关问题