0

如何以 flexigrid 方式触发行单击操作的常见操作?我希望在单击该行时重定向到单击的行的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
            });   
4

2 回答 2

2

我不确定 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");
});

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

于 2011-11-28T21:22:00.083 回答
-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

                });                                        


            });
    }
于 2014-11-18T08:55:26.710 回答