2011-11-28 48 views
0

如何触发一个共同的行动在行点击行动flexigrid的方式?我想,当该行被点击重定向到http://localhost/view/40(ID值)为点击行flexigrid on row点击

  $("#flex1").flexigrid({ 
       url: 'http://localhost/index.php/get_data', 
       dataType: 'json', 
       method: 'GET', 
       colModel : [ 
         {display: 'ID', name : 'id', width : 40, sortable : true}, 
         {display: 'A', name : 'a', width : 40, sortable : true}, 
        singleSelect {display: 'B', name : 'b', width : 40, sortable : true}, 
        ], 
       sortname: "id", 
       sortorder: "desc", 
       showTableToggleBtn: false, 
       resizable: false,      
       useRp: true, 
       rp: 30,      
       singleSelect: true, 
       usepager: true, 
       width: 'auto', 
       height: 100 
      }); 

回答

2

我不知道我的作品究竟如何​​flexigrid,但使用jqGrid的,并且通常是我做的是只需在网格外设置这些类型的操作即可。这确实需要一个通用的标记命名约定,但我假设flexigrid必须这样做。

举例来说,你可以看看你的Firebug中的HTML,看看哪些类或ID可能被分配到ID的列。也许它就像flexigrid行-ID或类似的

$('#flex1 tr[WHATEVER SELECTOR RENDERS IN YOUR GRID FOR THE ID COLUMN]').click(function(){ 
    // simulates similar behavior as an HTTP redirect 
     window.location.replace("http://localhost/view/40"); 
}); 

东西类只是确保你指定此事件网格完成后/加载

-1

这是我要做的事..

我加载网

jQuery("#sometable").flexigrid({ 
       url: 'http://localhost/get_data', 
       dataType: 'json', 
       colModel : [ 
        {display: 'id', name : 'id', width : 40, sortable : true, align: 'center', hide: true}, 
        {display: 'name ', name : 'Name', width : 150, sortable : false, align: 'left', hide: false}, 
        {display: 'image', name : 'LogoName', width : 100, sortable : true, align: 'left', hide: false} 
        ], 
        sortname: "id", 
        sortorder: "desc", 
        usepager: true, 
        singleSelect: true, 
        title: 'Some title', 
        useRp: true, 
        rp: 10, 
        width: 1000, 
        nowrap: false, 
        height: 'auto', 
        onSuccess : sometableonSuccess 
      }); 

,并在加载时..的onSuccess触发..

function sometableonSuccess(){ 
     jQuery('#sometable tr').each(function(){ 

       jQuery(this).click(function(){ 
         //Get the id of the row 
         var id = jQuery(this).find("td:eq(0)").text(); 
         //Do some action 

       });           


      }); 
    }