2010-02-24 84 views
2

我正在嘗試爲特定項目使用jqgrid列表。我閱讀了在線文檔,但找不到解決方案。我沒有列出和查看項目的問題。但是我需要在每一行中有一個按鈕,並且當點擊該按鈕時,瀏覽器應該被重定向到另一個頁面(該行可以被編輯,例如:?Section = news & Process = EditNews & NEWSID = 1)。jqgrid在點擊行時重定向到另一個頁面

我想我接近解決辦法,但停留在這一點上...

<script type="text/javascript"> 

    var lastsel; 

$(function() { 

    $("#list").jqGrid({ 
      url: '/FLPM/cp/news.cs.asp?Process=ViewNews', 
      datatype: 'xml', 
      mtype: 'Get', 
      height: '100%', 
      colNames: ['Actions','ID #','Page', 'Category Name', 'Active', 'Date Entered'], 
      colModel: [ 
       {name:'Actions', index:'Actions', width:100, sortable:false, search:false}, 
       {name:'ID', index:'ID', width:30}, 
       {name:'Title', index:'Title', width:360}, 
       {name:'Category', index:'Category', width:115}, 
       {name:'Active', index:'Active', width:40, editable:true, edittype:"select", editoptions:{value:"1:Yes;0:No"}}, 
       {name:'Date', index:'Date', width:126}, 
      ], 
      pager: jQuery('#pager'), 
      rowNum: 10, 
      rowList: [10,20,30], 
      sortname: 'Date', 
      sortorder: 'desc', 
      viewrecords: true, 
      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]; 
        de = "<input style='height:25px;width:25px;' type='button' value='DE' onclick=location.href='?Section=news&Process=EditNews&NEWSID='; />";    
        be = "<input style='height:25px;width:25px;' type='button' value='E' onclick=jQuery('#list').editRow("+cl+"); ></ids>"; 
        se = "<input style='height:25px;width:25px;' type='button' value='S' onclick=jQuery('#list').saveRow("+cl+"); />"; 
        ce = "<input style='height:25px;width:25px;' type='button' value='C' onclick=jQuery('#list').restoreRow("+cl+"); />"; 
        jQuery("#list").setRowData(ids[i],{Actions:de+be+se+ce}) 
       } 
      }, 
      editurl: "custompages.cs.asp?Process=EditPage",    
    }).navGrid("#pager",{edit:true,add:false,del:true});  

}); 
    </script> 
+0

只是好奇,你有沒有得到這個工作? – 2010-02-26 17:58:53

回答

1

爲了得到它的工作,我需要一個ID添加到de元素:

id='"+cl+"_buttonEditTest' 

我還需要將Actions更改爲act以便讓控件實際顯示在每一行中:

jQuery("#list").setRowData(ids[i],{act:de+be+se+ce}) 

此外,你可能想行的ID添加到您的鏈接:

onclick=location.href='?Section=news&Process=EditNews&NEWSID="+cl+"'; 

所以最後的代碼是:

de = "<input style='height:25px;width:25px;' type='button' value='DE' onclick=location.href='?Section=news&Process=EditNews&NEWSID="+cl+"'; id='"+cl+"_buttonEditTest' />";    
be = "<input style='height:25px;width:25px;' type='button' value='E' onclick=jQuery('#list').editRow("+cl+"); ></ids>"; 
se = "<input style='height:25px;width:25px;' type='button' value='S' onclick=jQuery('#list').saveRow("+cl+"); />"; 
ce = "<input style='height:25px;width:25px;' type='button' value='C' onclick=jQuery('#list').restoreRow("+cl+"); />"; 
jQuery("#list").setRowData(ids[i],{act:de+be+se+ce}) ; 
相關問題