行点击上的 Flexigrid

发布于 2024-12-18 06:09:19 字数 1029 浏览 1 评论 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
            });   

How can I trigger a common action on a row click action the flexigrid way? I want when the row is clicked to redirect to http://localhost/view/40 (the value of ID) for the clicked 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
            });   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深白境迁sunset 2024-12-25 06:09:19

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

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

I'm not sure exactly how flexigrid works, but I use jqGrid, and commonly what I do is to just set these type of actions outside the grid. this does require a common markup naming convention, but I'm assuming flexigrid must do this.

so for example, you can take a look at your HTML in Firebug and see what classes or id might get assigned to the column for ID. maybe its a class like flexigrid-row-id or something like that

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

just make sure you assign this event after your grid has completed/loaded

热鲨 2024-12-25 06:09:19

我就是这样做的..

我加载网格

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

                });                                        


            });
    }

This is how I do it..

I load the grid

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

and when it loads.. onSuccess triggers..

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

                });                                        


            });
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文