简体   繁体   English

如何在动态标签中添加内容

[英]How to add content in dynamic tab

I have a jqQrid that I have placed inside a HTML table. 我有一个放置在HTML表中的jqQrid。 Now as per my requirement I have to show this grid inside the dynamic tab which is opened on hyper link click. 现在,根据我的要求,我必须在超级链接单击时打开的动态选项卡中显示此网格。

Here is the code for dynamic tab creation: 这是用于动态标签创建的代码:

function addTab(title) {
    if ($('#tt').tabs('exists', title)) {
        $('#tt').tabs('select', title);
    }
    else {
        if (title == "Check in List") {
            //Here i have to call jqgrid loading function but how I am not getting !!!
            var content = '';
        }
        else {
            var content = '<p>Hii</p>';
        }
        $('#tt').tabs('add', {
            title: title,
            content: content,
            closable: true
        });
    }
}

Here is the function to generate the grid: 这是生成网格的功能:

function CheckInRecordgrid() {
    //Grid Codes 
}

And here is the HTML table placeholder: 这是HTML表格的占位符:

<table id="CheckIngrid"></table>

Now my question is how to call the grid generation function if the clicked tab is as per the condition? 现在我的问题是,如果单击的选项卡符合条件,如何调用网格生成函数?

Here is my full grid code.. 这是我的完整网格代码。

        function CheckInRecordgrid() {
        var data = [[48803, "DELUX", "A", "2014-09-12 12:30:00", "Done"], [48804, "NORAML", "V", "2014-09-12 14:30:00", "Pending"]];

        $("#CheckIngrid").jqGrid({
            datatype: "local",
            height: '100%',
            autowidth: true,
            colNames: ['Room No.', 'Category', ' Guest name', ' Date & Time ', 'Status'],
            colModel: [
                    {
                        name: 'Room No.', index: 'Room No.', width: 100, align: 'center'
                    },
                    {
                        name: 'Category', index: 'Category', width: 100, align: 'center'
                    },
                    {
                        name: 'Guest name', index: 'Guest name', width: 100, align: 'center'
                    },
                    {
                        name: 'Date & Time', index: 'Date & Time', width: 100, align: 'center'
                    },
                    {
                        name: 'status', index: 'status', width: 100, align: 'center'
                    }
                ],
            caption: "Check In List"
        });

        var names = ["Room No.", "Category", "Guest name", "Date & Time", "status"];
        var mydata = [];

        for (var i = 0; i < data.length; i++) {
            mydata[i] = {};
            for (var j = 0; j < data[i].length; j++) {
                mydata[i][names[j]] = data[i][j];
            }
        }

        for (var i = 0; i <= mydata.length; i++) {
            $("#CheckIngrid").jqGrid('addRowData', i + 1, mydata[i]);
        }
    }

try this 尝试这个

  if (title == "Check in List") {
     var content = '';
  }else {
     var content = '<p>Hii</p>';
  };

  $('#tt').tabs('add', {
      title: title,
      content: content,
      closable: true,
  }).tabs({
      onAdd: function(title,index){
           if (title == "Check in List") {
             CheckInRecordgrid();
           }
      }
  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM