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” ); –