1
這是JqGrid.In在這裏有一個GridSearch.In問題,在這裏我把InvoiceId作爲搜索。但它不工作,但它顯示加載面板,當我點擊搜索按鈕。JqGrid搜索不起作用
我的數據類型是Json.I看到有一個鏈接正在工作,我也試圖做到這一點,但它不適用於我的方案。 LINK
<script type="text/javascript">
$(function() {
$('#jqgrid').jqGrid({
url: 'Sales/GetAllSalesOrders/',
datatype: 'json',
mtype: 'GET',
//columns names
colNames: ['InvoiceId', 'CustomerId', 'SubTotal', 'TotalDiscount', 'VAT', 'NBT', 'Amount', 'Balance'],
//columns model
colModel: [
{ name: 'InvoiceId', index: 'InvoiceId', align: 'left' },
{ name: 'CustomerId', index: 'CustomerId', align: 'left' },
{ name: 'SubTotal', index: 'SubTotal', align: 'left' },
{ name: 'FullDiscount', index: 'FullDiscount', align: 'left' },
{ name: 'Vat', index: 'Vat', align: 'left' },
{ name: 'Nbt', index: 'Nbt', align: 'left' },
//{ name: 'Total', index: 'Total', align: 'left' },
{ name: 'NetAmount', index: 'NetAmount', align: 'left' },
{ name: 'Balance', index: 'Balance', align: 'left' }
],
pager: $('#jqgrid'),
rowNum: 10,
sortname: 'InvoiceId',
sortorder: 'asc',
viewrecords: true,
width: 'auto',
height: 'auto',
rowNum: 50,
rowTotal: 200,
rowList: [20, 30, 50, 100],
rownumbers: false,
rownumWidth: 40,
subGrid: true,
//subrid model
subGridModel: [{
//subgrid columns names
// name: ['InvoiceItemId', 'Quantity', 'Rate', 'DiscountAmount', 'Amount'],
name: ['InvoiceItemId', 'Quantity'],
width: [100, 100],
align: ['left', 'left'],
//data: { id: id }
}],
//url from which subgrid data should be requested
subGridUrl: '/Sales/GetSalesItemsByInvoiceId/'
});
});
$("#mySearch").click(function() {
debugger;
var grid = $("#jqgrid");
var text = $("#searchText").val();
var postdata = grid.jqGrid('getGridParam', 'postData');
$.extend(postdata,
{
filters: '',
searchField: 'InvoiceId',
searchOper: 'eq',
searchString: 'text',
});
grid.jqGrid('setGridParam', { search: true, postData: postdata });
grid.trigger("reloadGrid", [{ page: 1 }]);
});
</script>
變更後工作。謝謝 – TechGuy 2014-09-24 10:29:18