单击行上的柔性网格



如何以灵活网格的方式触发行单击操作的共同操作?我想当行被单击重定向到http://localhost/view/40 (ID的值)为被单击的行

            $("#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
            });   

我不确定flexigrid是如何工作的,但我使用jqGrid,通常我所做的就是在网格之外设置这些类型的操作。这确实需要一个通用的标记命名约定,但我假设flexigrid必须这样做。

例如,您可以查看Firebug中的HTML,看看哪些类或id可能被分配给id的列。也许是flexigrid-row-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");
});

请确保在网格完成/加载后分配此事件

我是这样做的

加载网格

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
                });                                        

            });
    }

最新更新