Newbie question regarding loading


Loving the controls. :smiley:

I have one small problem which is eluding me. I am trying to incorporate the grid control in my php project. I am using an MVC pattern which means I cannot create the necessary JSON or XML in memory structures until the page is rendering past the tag. I hope this makes sense?

In other words, following the examples, where I create a simple XML file called “step3.xml” it only loads the XML if I do it in the init function I create inside the header tags.

I have tried calling the loadXML method from a script tag within the main body, but it doesn’t work. Weirdly if I create a button, and assign onclick to ‘mygrid.loadXML(“step3.xml”);’ then it works just fine. However I can’t expect the end user to wait for the page to load, and then click a button to load the data.

So in summary, I am using MVC, so my block is inside a standard template so I cannot put grid specific code in there, can I do this from within the tag?

Apologies if already posted, I did search the forum first and couldn’t find anything specifically relating to this problem.


OK I managed to get a basic grid working, loading an in memory JSON object. :smiley:

But when I try to apply it to my application all I get is the grid with the columns. Ie it doesn’t load the data.

I post the rendered code here to see if anyone can spot what I am missing.

<script type="text/javascript">
data = { 
		 { id:1, 
		"1"] } 
	grid = new dhtmlXGridObject('mygrid_container');
    grid.setHeader("Day,Ref1,Ref2,Bank1,Bank2,Bank3,Bank4,Bank5,Bank6,Er,EU,Non Ledger VAT, Total Sales Ledger Receipts,An01,An02,An03,An04,An05,An06,An07,An08,An09,An10,Fixed Asset Sales, Net, Quick Entry No, Quick Entry Name, Comment, Month No");
    grid.setInitWidths("50,50,50,100,100,100,100,100,100,50,50, 50, 100,100,50,50,50,50,50,50,50,50,50,50,100,50,50,100,100");

It turns out that setting the height of the div to say 60% just shows the headers. If you set it to something in pixels, eg 270px like in the demo then you can see the added row.


Is it possible to set the height to a dynamic size at all?

Please ,try to add sizes to your html body for correct init of the dynamic height of the grid.
For example:

<style> html,body { height: 100%; margin: 0px; overflow: hidden; } </style>