网格

2016-02-13 18 views
0

这里是格如下:网格

if (responseJSON) { 
    showObjects(['anTable']); 
    showObjects(['dist']); 
    $('gridtab').innerHTML = ''; 
    var wordStructure = [{ 
     field: 'alpha', 
     name: 'Alpa Dictionary', 
     width: '200px' 
    }, { 
     field: 'numbers', 
     name: 'Number Format', 
     width: '200px' 
    }, { 
     field: 'words', 
     name: 'Normal words', 
     width: '200px' 
    }]; 
    var wordStore = []; 
} 

下面是HTML表,如下所示,其是将被显示为弹出与上面的网格:

<table cellpadding='15' cellspacing='15' id="dist" style="display: none; width:auto"> 
    <tr> 
    <td> 
     <div id="gridtab" style="width: 400%; font-size: 11pt; font-family: arial; border: 1px solid #fff; padding: 5px;"></div> 
    </td> 
    </tr> 
    <tr> 
    <td> 
     <center> 
     <button dojoType="dijit.form.Button" preventCache='true' useCache='false' cacheContent='false' onclick="getSelectedNormalWords();">Ok</button> 
     <button dojoType="dijit.form.Button" preventCache='true' useCache='false' cacheContent='false'>Cancel</button> 
     </center> 
    </td> 
    </tr> 
</table> 

showOjects(['dist'])只是显示带有表格的网格,但我想将其显示为弹出式窗口。

function showObjects(objArray) { 
    for (var i = 0; i < objArray.length; i++) { 
     $(objArray[i]).style.display = 'block'; 
    } 
} 
+0

这是不相关的答案,但弹出窗口越来越过时。许多浏览器阻止弹出窗口。他们也有很多缺点,这就是为什么越来越多的人将弹出窗口切换到模态。 –

+0

丹尼尔张非常感谢你的回应。但我需要根据我的项目显示它作为弹出窗口。 – Anusha

+0

当你说“弹出”时,你的意思是一个完全独立的浏览器窗口,或只是弹出现有内容的东西?例如,像Dijit对话框那样工作? – jason0x43

回答

0

假设您实际上并不需要打开新窗口,那么可以使用Dijit Dialog。基本的想法是创建一个对话框并将对话框的内容设置为您的内容。假设你正在使用的Dojo一个合理的现代版,这可能看起来像(这个代码是未经测试):

function showTable(tableId) { 
    // You wouldn't normally do a `require` in a handler function like 
    // this, but it should work in this case 
    require([ 'dijit/Dialog' ], function (Dialog) { 
     // Pull the table out of the DOM 
     var table = document.getElementById('dist'); 
     table.parentNode.removeChild(table); 

     // Set the table's display style to block so it will be visible 
     // when it's re-inserted into the DOM 
     table.style.display = 'block'; 

     // Create and show a new Dialog with the table as it's content 
     var dlg = new Dialog({ content: table }); 
     dlg.show(); 
    }); 
}