0
嗨通過使用下面的代碼,我可以加載XML數據轉換成DHTMLXGrid,其工作的罰款。但是當我嘗試以Json格式加載相同的數據時,它不起作用。我要求你有人來幫助我。我使用JSON試圖對這個代碼的一切,但:(:(你的幫助是非常讚賞,我需要一個工作示例。如何將外部json文件加載到dhtmlx Grid中?
<script type="text/javascript">
dhtmlx.image_path = "codebase/imgs/";
dhtmlxEvent(window,"load",function(){
var layout = new dhtmlXLayoutObject(document.body,"2U");
layout.cells("a").setText("Contacts");
layout.cells("b").setText("Contact Details");
layout.cells("b").setWidth(500);
var menu = layout.attachMenu();
menu.setIconsPath("icons/");
menu.loadStruct("data/menu.xml");
var toolbar = layout.attachToolbar();
toolbar.setIconsPath("icons/");
toolbar.loadStruct("data/toolbar.xml");
var contactsGrid = layout.cells("a").attachGrid();
contactsGrid.setHeader("Name,Last Name,Email"); //sets the headers of columns
contactsGrid.setColumnIds("fname,lname,email"); //sets the columns' ids
contactsGrid.setInitWidths("250,250,*"); //sets the initial widths of columns
contactsGrid.setColAlign("left,left,left"); //sets the alignment of columns
contactsGrid.setColTypes("ro,ro,ro"); //sets the types of columns
contactsGrid.setColSorting("str,str,str"); //sets the sorting types of columns
contactsGrid.init();
contactsGrid.loadXML("data/data.xml",true,true);
});
</script>
我應通過使用contactsGrid.load(讀取data.json文件數據 「數據/ data.json」, 「JSON」 ); –