我希望得到JqGrid包含页面,每页记录,搜索参数等我的ajax服务的最后一个请求的完整URL.
JqGrid api中是否有任何方法或方法集合可用于实现此目的?
我对jQuery很新,刚开始使用jqGrid.我查看了jqGrid文档,以便弄清楚如何显示我在网格中以JSON格式接收的一些数据无济于事.当我创建网格时,它会显示正确的标题,寻呼机信息等,并通过Firebug,我可以看到JSON数据的请求和响应.下面的jsonReader是我尝试过的众多之一,在函数回调中,我可以记录我收到的具体值,所以我知道我正在获取数据.
我将下面指定的JSON加载到jqGrid中的正确方法是什么?
这是相关的代码:
HTML:
<div id="dataInfo">
<table id="dataTable"></table>
<div id="dataTablePager"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
jQuery("#dataTable").jqGrid({
url: 'http://<snip>',
mtype: 'GET',
datatype: 'json',
jsonReader: {
root: 'ipResponses',
id: 'startIP',
repeatitems: false,
page: function(obj) { return 1; },
total: function(obj) { return 1; },
records: function(obj) { return obj.ipInfo.ipResponses.length; },
userdata: "userData"
},
colNames: ['StartIP', 'EndIP'],
colModel: [
{
name: 'startIP',
index: 'startIP',
width: 55
},
{
name: 'endIP',
index: 'endIP',
width: 55
}
],
pager: '#dataTablePager',
rowNum: 8,
rowList: [25,50,100],
sortname: 'startIP',
sortorder: 'asc', …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用刚刚更改的新数据重新加载网格,以便用户可以看到修改后的新数据。
我的方法:
jQuery("#relCasePick").click( function(){
var ids=jQuery("#list10").jqGrid('getGridParam','selarrrow');
$.ajax({
type: "POST",
url: "/cpsb/unprocessedOrders.do?method=releaseToCasePick&orderNumbers="+ids,
data: JSON.stringify(ids),
dataType: "json"
});
jQuery("#list10").setGridParam({rowNum:10,datatype:"json"}).trigger('reloadGrid');
});
Run Code Online (Sandbox Code Playgroud)
当我点击这个按钮时..我正在正确发送数据但是当我重新加载它没有用新数据更新时..如果有人可以帮助我将不胜感激..
嗨我有一个带有子网格的jqgrid,它调用了一个servlet.我正在使用POST向servlet发送一些数据,但是在调用子网格时不会发送相同的数据.这是我的JS:
$("#testsTable").jqGrid({
mtype: "POST",
url: "GetCurrentStatusServlet",
postData: {buildPath :"C:\\Test\\01"},
datatype: "xml",
colNames:['TestCase Name', 'Last Update', 'Status'],
colModel:[
{name:'name',index:'name', width:90},
{name:'lastupdate',index:'lastupdate', width:100},
{name:'status',index:'status', width:80, align:"right"}
],
rowNum:10,
autowidth: true,
rowList:[10,20,30],
pager: $('#pager1'),
sortname: 'id',
viewrecords: true,
multiselect: true,
caption: "Tests",
sortorder: "desc",
subGrid: true,
subGridUrl : "GetCurrentStatusServlet",
subGridModel: [ {
name: ['TestCase Name', 'Last Update', 'Status'],
width : [100, 200, 80],
params: ['name']}]
}).navGrid('#pager1',{edit:false,add:false,del:false});
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能将postData也发送到子网格servlet?有没有办法指定subgridPostData?谢谢.
我是jqGrid的第一次用户,到目前为止我通过官方示例,我有兴趣使用json将数据加载到网格中.
我目前正在查看,正在加载数据(JSON数据):http: //trirand.com/blog/jqgrid/jqgrid.html
这里有一些创建网格的javascript:
jQuery("#list2").jqGrid(
{
url : '<c:url value="${webappRoot}/getdetails" />',
datatype : "json",
colNames : [ 'id', 'Location', 'Country Code', 'Type', 'Interval',
'Version', 'Last Active', 'Last Login', 'NOTE' ],
colModel : [
{ name : 'id', width : 10 },
{ name : 'location', width : 75 },
{ name : 'countryCode', width : 50 },
{ name : 'type', width : 40 },
{ name : 'interval', width : 30 },
{ name : 'version', width …Run Code Online (Sandbox Code Playgroud) 它在jqgrid文档中声明下面的代码应允许使用服务器端分页进行本地排序; 网格数据在分页时消失; 之前已经问过这个问题没有明确的答案 - 使用loadonce的建议:true表示分页已关闭 - 我需要分页
稍后编辑完整的html页面和json响应(我现在从php/mysql后端运行).
我的完整HTML页面
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JQGrid Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../dojoproject/jquery-ui-1.8.16.custom/css/start/jquery-ui-1.8.16.custom.css">
<link rel="stylesheet" type="text/css" href="jquery.jqGrid-4.3.1/css/ui.jqgrid.css">
<style type="text/css">
html, body {
margin: 0;
padding: 0;
font-size: 90%;
}
</style>
<script type="text/javascript" src="../dojoproject/jquery-ui-1.8.16.custom/js/jquery-1.6.2.min.js" ></script>
<script type="text/javascript" src="../dojoproject/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js" ></script>
<script type="text/javascript" src="jquery.jqGrid-4.3.1/js/i18n/grid.locale-en.js" ></script>
<script type="text/javascript" src="jquery.jqGrid-4.3.1/js/jquery.jqGrid.min.js" ></script>
<script type="text/javascript" src="../dojoproject/jqGrid-4.1.2/js/JSON-js/json2.js" ></script>
<script>
$(function() {
$('#table').jqGrid({
jsonReader : {
repeatitems: false,
cell:"",
id:"0"
},
height:'auto',
url:'/jqgrid/orderdetails.php', …Run Code Online (Sandbox Code Playgroud) 我是jqGrid的首发,我在页面中有2个jqGrid,在Grid1中我有inCustom和OutCustom我希望用户点击Grid获取Data inCustom和outCustom来编写这段代码
var grid = $('#list');
grid.jqGrid({
url: 'jQGridHandler.ashx',
postData: { ActionPage: 'ClearanceRequest', Action: 'Fill' },
ajaxGridOptions: { cache: false },
loadonce: true,
direction: "rtl",
datatype: 'json',
height: 600,
width: 1000,
colNames: ['', '', '', ' ', '', '', '', '', '',
'', '', ' ', '', '', '', '', '', '',
'', ' ', '', '', '', '',
'', '', '', '', '', '', ' ',
'', '', '', '', '', ''],
colModel: [
{ name: 'REQUEST_ID', width: 100, …Run Code Online (Sandbox Code Playgroud) 我已经对此做了一些研究,但大多数解决方案都是针对MVC ..我只是使用Asp.net 3.5如何在按钮点击时实现这一点..我应该包括任何库或其他任何东西..请帮助..
我有很多列的jqGrid表.使用过滤器工具栏在网格中搜索.对于大多数人来说,搜索只是简单的默认运算符.对于一个datetime列,我想要不同类型的运算符和datepicker选择器.我已经添加了dataInitdatepicker初始化searchoptions,必要的运算符searchoptions.sopt.为了显示这个运算符,我将searchOperators设置为true.所以对于这个专栏,一切都还可以.我有带操作符选择器弹出窗口的datepicker.但对于所有其他列,默认运算符图标显示在其左侧.操作员是默认的并且用户无法更改它,这很烦人.那么有可能使用jqGrid API隐藏它们吗?据我所见,我只能使用我的自定义代码隐藏它:
我需要检查我的列模型并在渲染网格(可能在loadComplete)之后检查所有具有空的列sopt或sopt.length == 0删除操作符选择器.或者添加隐藏它的CSS类.不确定哪个解决方案更好(隐藏或删除),因为删除可能会破坏某些逻辑,隐藏可能会影响宽度计算.这是我在小提琴上的意思的样本
function fixSearchOperators()
{
var columns = jQuery("#grid").jqGrid ('getGridParam', 'colModel');
var gridContainer = $("#grid").parents(".ui-jqgrid");
var filterToolbar = $("tr.ui-search-toolbar", gridContainer);
filterToolbar.find("th").each(function()
{
var index = $(this).index();
if(!(columns[index].searchoptions &&
columns[index].searchoptions.sopt &&
columns[index].searchoptions.sopt.length>1))
{
$(this).find(".ui-search-oper").hide();
}
});
}
Run Code Online (Sandbox Code Playgroud)
有没有人有更好的想法?
place_id的custom_value设置为我先点击的任何一行.无论实际值如何,后续单击的行都将使用相同的值.为什么?
例:
place_id foo_name bar_value
10 blah abc
11 blah2 fgr
Run Code Online (Sandbox Code Playgroud)
单击place_id为10的行,然后单击"编辑",出现的表单将包含10place_id值.进行更改并保存,然后单击下一行.10虽然所有其他值都是正确的,但表单仍将具有place_id .
我的代码:
列place_id如下所示:
{name:'place_id', index:'place_id', editable: true, edittype:'custom',
editoptions: { custom_element:myelem,custom_value:myval }}
Run Code Online (Sandbox Code Playgroud)
该myval功能是:
function myval(elem){
return elem.val();
}
Run Code Online (Sandbox Code Playgroud)
我需要的是将myval设置为正在编辑的行的正确place_id.我看着elemFirebug 中的对象,我发现它总是具有第一次点击的行的值,但我不明白为什么我也不知道从哪里可以获取正确的值.任何建议都表示赞赏(我试过在jqgrid论坛上询问,但没有任何结果,所以我转向stackoverflow).
*编辑:如果我使用edittype:'text'而不是edittype:'custom'我得到显示和传递的正确值,但该列是可编辑的,它应该只是可见但不可编辑.
完整代码:
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
url:'/foo/bar/results',
datatype: 'json',
mtype: 'POST',
colNames:['Place ID', 'Site ID', 'Site Name', 'API ID', 'M Type'],
colModel :[
{name:'place_id', index:'place_id', key: true, sorttype:'integer',
width:70, editable: true, edittype:'custom',
editoptions: {custom_element:myelem,custom_value:myval }},
{name:'site_id', index:'site_id', sorttype:'integer', …Run Code Online (Sandbox Code Playgroud)