2009-06-16 218 views
0

我很努力,我不明白我的代碼中缺少什麼。在jqgrid上實現搜索功能?

ASP:

SEARCHFIELD = Request.QueryString("SEARCHFIELD") 
SEARCHSTRING = Request.QueryString("SEARCHSTRING") 
SEARCHOPER = Request.QueryString("SEARCHOPER") 

的JavaScript:

var lastsel; 

$(function() { 

$("#list").jqGrid({ 
     url: 'orders.cs.asp?Process=ViewOrders', 
     datatype: 'xml', 
     mtype: 'Get', 
     height: '100%', 
     colNames: ['Actions','ID #','Customer', 'Date', 'Status','Total','Tracking #'], 
     colModel: [ 
      {name:'Actions', index:'Actions', width:65, sortable:false, search:false}, 
      {name:'ID', index:'ID', width:30}, 
      {name:'Customer', index:'Customer', width:150}, 
      {name:'Date', index:'Date', width:150}, 
      {name:'TransactStatus', index:'TransactStatus', width:130, editable:true, edittype:"select", editoptions:{value:"Pending:Pending;Awaiting Payment:Awaiting Payment;Awaiting Fulfillment:Awaiting Fulfillment;Awaiting Shipment:Awaiting Shipment;Awaiting Pickup:Awaiting Pickup;Partially Shipped:Partially Shipped;Completed:Completed;Shipped:Shipped;Cancelled:Cancelled;Declined:Declined;Refunded:Refunded"}}, 
      {name:'Total', index:'Total', width:80, align:"right"}, 
      {name:'ShipTrackingNumber', index:'ShipTrackingNumber', width:126, editable:true}, 
     ], 
     pager: jQuery('#pager'), 
     rowNum: 10, 
     rowList: [10,20,30], 
     sortname: 'Date', 
     sortorder: 'desc', 
     viewrecords: true, 
     subGrid : true, 
     subGridUrl: 'orders.cs.asp?Process=ViewOrderDetails', 
     subGridModel: [ { 
      name: ['Quantity','Product','-', '-', '-'], 
      width : [65,350,50,50,50], 
      param: ['invdate'] 
      } 
     ], 
     imgpath: 'js/jqGrid/themes/basic/images', 
     onSelectRow: function(id) { 
      if(id && id!==lastsel) { 
       $('#list').restoreRow(lastsel); 
       $('#list').editRow(id,true); 
       lastsel=id; 
       } 
      }, 
     loadComplete: function(){ 
      var ids = jQuery("#list").getDataIDs(); 
      for(var i=0;i<ids.length;i++){ 
       var cl = ids[i]; 
       be = "<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('#list').editRow("+cl+"); ></ids>"; 
       se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('#list').saveRow("+cl+"); />"; 
       ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=jQuery('#list').restoreRow("+cl+"); />"; 
       jQuery("#list").setRowData(ids[i],{Actions:be+se+ce}) 
      } 
     }, 
     editurl: "orders.cs.asp?Process=EditOrder", 
}).navGrid("#pager",{edit:true,add:false,del:false}); 

}); 
+0

你需要告訴使用你打算什麼和錯在哪裏。 – AnthonyWJones 2009-06-16 08:22:09

+0

它不工作,它沒有給出任何錯誤。我認爲演示網站是顯示出現問題的最佳方式。 http://refinethetaste.com/html/cp/?Section=orders&Process=ViewOrders http://refinethetaste.com/html/cp/orders.cs.asp?Process=ViewOrders&ROWS=10&SIDX=Date&SORD=asc&SEARCHFIELD= ID&SEARCHSTRING = 1&SEARCHOPER =等於 – Efe 2009-06-16 17:12:30

回答

0

當我嘗試你比如搜索,得到所有客戶凡客列包含Yavuz的。

然後我得到下面的錯誤(我可以看到這個與螢火蟲):一個非布爾類型的表達式中指定一個條件的預期,在')'附近。

您的SQL語句可能有些問題。