<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.infragistics.com/community/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Damyan Petev's Blog : 11.2, CDN, Infragistics, NetAdvantage, CSS3</title><link>http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/11.2/CDN/Infragistics/NetAdvantage/CSS3/default.aspx</link><description>Tags: 11.2, CDN, Infragistics, NetAdvantage, CSS3</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP3 (Build: 36.8414)</generator><item><title>jQuery Hierarchical Grid - Load On Demand</title><link>http://www.infragistics.com/community/blogs/damyan_petev/archive/2012/02/15/jquery-hierarchical-grid-load-on-demand.aspx</link><pubDate>Wed, 15 Feb 2012 13:00:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:332605</guid><dc:creator>[Infragistics] Damyan Petev</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infragistics.com/community/blogs/damyan_petev/rsscomments.aspx?PostID=332605</wfw:commentRss><comments>http://www.infragistics.com/community/blogs/damyan_petev/archive/2012/02/15/jquery-hierarchical-grid-load-on-demand.aspx#comments</comments><description>&lt;p&gt;The Hierarchical Grid (a fairly recent addition to our NetAdvatage for jQuery) is a client-side control that can display hierarchical ( or nested data if you will, the kind of stuff you would use an Org chart or a tree of some sorts to visualize). Now while in some cases other controls just may do, when presented with large amount of information and it requires a table-like representation then the igHierarchicalGrid should definitely be your go-to control. Using a hierarchical grid representation is a amazing reduction in terms of space required per data unit as it allows for not only child layouts to be collapsed and expanded but also provides paging and all the things you&amp;rsquo;d expect from a grid. And while this is all great, it kind of makes you wonder where else you can save up some. There is, in fact, a very obvious route to take &amp;ndash; collapsing and expanding layouts sounds like a great target &amp;ndash; why have them while they are not visible? That is indeed the right question. You can say we have thought about that as such way of thinking is in the very design of the control &amp;ndash; the hierarchical grid is relying on the flat igGrid control to display child layouts and it creates an instance &lt;strong&gt;&lt;em&gt;only&lt;/em&gt;&lt;/strong&gt; when a row is actually expanded. What this means is that all the markup (HTML elements) that might represent a 50 rows worth of child entries would not be created and sit around until and if the user decides to expand their parent row. This reduces the total resources required and at the end of the day it equals performance boost. &amp;ldquo;Good!&amp;rdquo;, you might say, yet there is .. more! The Hierarchical Grid is already taking care of its child UI elements for you, but what about the data? Of course that essential side has not been forgotten and the igHierarchicalGrid comes with a &amp;lsquo;Load On Demand&amp;rsquo; support. What this brings is the ability to load data only when it is required making that control that much more lightweight and while enabling it, you also lay the foundations for some other nifty features such a remote paging, filtering and sorting. You are, however, required to give it a little push, so keep reading to see how to do just that!&lt;/p&gt;
&lt;p&gt;Also here&amp;rsquo;s and inspirational screenshot of that all-time favourite spinning indicator users would and should see when they must be informed something in the background is happening and that is pretty much the only indication something like Load On Demand is active. Keep in mind this took several attempts to nail the split-second the indicator is visible, so bear with me on its aesthetics :)&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.infragistics.com/community/Release/11.2/JQUERY/Hierarchical_Grid-Load_On_Demand/jQuery-Hierarchical-Grid_Load-on-Demand.png" title="jQuery Hierarchical Grid Loading on Demand" alt="jQuery Hierarchical Grid Loading on Demand" /&gt;&lt;/p&gt;
&lt;h1&gt;Load on Demand with jQuery &lt;/h1&gt;
&lt;p&gt;Now if you&amp;rsquo;ve been examining the jQuery API of the Hierarchical Grid you might be wondering where is that &amp;lsquo;loadOnDemand&amp;rsquo; property? Simply put, the jQuery widget doesn&amp;rsquo;t really have one. To be completely thorough&amp;hellip; the ASP.NET MVC helper does have one (as it sets up some behind-the-scenes server magic) but more on that later on. The widget doesn&amp;rsquo;t need that as it is a client control completely independent from server technology and as such in no way does it implement loading data on demand, but rather it should be made aware of such opportunity and if the proper setting are in place the grid will take advantage of it. With that said, the control can consume &lt;a title="Open Data Protocol (OData) homepage." href="http://www.odata.org/" target="_blank"&gt;OData (Open Data Protocol)&lt;/a&gt; and with the very nature of the protocol that spells querying data (including paging, ordering and filtering) what follows seems completely natural &amp;ndash; when presented with OData the grid will use it to request data only when needed &amp;ndash; yes, loading it demand. That means that if you have your information exposed with OData protocol you are almost ready! All that is left to do to get the feature is three properties:&lt;/p&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0cf15aef-f333-4962-a631-96ec22a40bbb" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#ddd;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt;
&lt;li&gt;$(&lt;span style="color:#800000;"&gt;&amp;quot;#hierarchicalGrid&amp;quot;&lt;/span&gt;).igHierarchicalGrid({&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#006400;"&gt;//--Set up for Load on demand follows:&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;odata: &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;initialDataBindDepth: 0,&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dataSource: oDataInJson,&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;responseDataKey: &lt;span style="color:#800000;"&gt;&amp;#39;d&amp;#39;&lt;/span&gt;,&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#006400;"&gt;//--end--&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;autoGenerateColumns: &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;primaryKey: &lt;span style="color:#800000;"&gt;&amp;quot;ID&amp;quot;&lt;/span&gt;,&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;columnLayouts: [&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name: &lt;span style="color:#800000;"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;responseDataKey: &lt;span style="color:#800000;"&gt;&amp;#39;d&amp;#39;&lt;/span&gt;,&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;childrenDataProperty: &lt;span style="color:#800000;"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;autoGenerateColumns: &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;,&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;primaryKey: &lt;span style="color:#800000;"&gt;&amp;quot;ID&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;],&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;width: &lt;span style="color:#800000;"&gt;&amp;quot;700px&amp;quot;&lt;/span&gt;,&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;});&lt;/li&gt;
&lt;/ol&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As seen in lines 4 through 7 there isn&amp;rsquo;t all too much complication about it &amp;ndash; make the grid aware OData will be used (setting the respective property to &amp;lsquo;true&amp;rsquo;) and provide a source. &lt;/p&gt;
&lt;p&gt;The initial data bind depth is obligatory and it tells the grid just how much in the nested data structure should it dig right from the start and while usually that means setting it to as many levels your data has or even &amp;ndash;1 for the &amp;ldquo;I don&amp;rsquo;t know! Can&amp;rsquo;t you just figure it out and load everything?&amp;rdquo; case, when the goal is loading on demand you want that to be zero &amp;ndash; as in just the first(parent) tier of entries will be loaded.&lt;/p&gt;
&lt;p&gt;The response key is telling the grid how to look at your data and is specific to it as well. It is only needed when that data is wrapped and it points to where the array of records is. Let&amp;rsquo;s have a more descriptive example &amp;ndash; as seen above is is set to &amp;lsquo;d&amp;rsquo; and that is because in that demo the sample OData service response looks like.. &lt;/p&gt;
&lt;div style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;width:97.5%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;padding:4px;" id="codeSnippetWrapper"&gt;
&lt;div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;" id="codeSnippet"&gt;
&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; ?({&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;d&amp;quot;&lt;/span&gt; : [&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;__metadata&amp;quot;&lt;/span&gt;: {&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;uri&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;http://services.odata.org/OData/OData.svc/Categories(0)&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;ODataDemo.Category&amp;quot;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt; }, &lt;span style="color:#006080;"&gt;&amp;quot;ID&amp;quot;&lt;/span&gt;: 0, &lt;span style="color:#006080;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;Food&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;: {&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//rest is omitted&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now take the NorthWind sample service for example:&lt;/p&gt;
&lt;div style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;width:97.5%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;padding:4px;" id="codeSnippetWrapper"&gt;
&lt;div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;" id="codeSnippet"&gt;
&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; ?({&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;d&amp;quot;&lt;/span&gt; : {&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;results&amp;quot;&lt;/span&gt;: [&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;__metadata&amp;quot;&lt;/span&gt;: {&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;uri&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;http://services.odata.org/Northwind/Northwind.svc/Customers(&amp;#39;ALFKI&amp;#39;)&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;NorthwindModel.Customer&amp;quot;&lt;/span&gt;&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt; }, &lt;span style="color:#006080;"&gt;&amp;quot;CustomerID&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;ALFKI&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;CompanyName&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;Alfreds Futterkiste&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;ContactName&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;Maria Anders&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;ContactTitle&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;Sales Representative&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Address&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;Obere Str. 57&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;City&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;Berlin&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Region&amp;quot;&lt;/span&gt;: &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;PostalCode&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;12209&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Country&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;Germany&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Phone&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;030-0074321&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Fax&amp;quot;&lt;/span&gt;: &lt;span style="color:#006080;"&gt;&amp;quot;030-0076545&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Orders&amp;quot;&lt;/span&gt;: {&lt;/pre&gt;

&lt;pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//rest is omitted&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this case the response key would be &amp;ldquo;d.results&amp;rdquo;. Simple enough and again specific to how you present your data.&lt;/p&gt;
&lt;p&gt;In the light of all this you can check out Taz&amp;rsquo;s blog on &lt;a title="A blog on using OData with jQuery Hierarchical Grid by Taz Abdeali" href="http://blogs.infragistics.com/blogs/taz_abdeali/archive/2012/01/24/using-odata-with-jquery-hierarchical-grid.aspx" target="_blank"&gt;Using OData with jQuery Hierarchical Grid&lt;/a&gt; where you can find not only a full guide but also a link to a live demo!&lt;/p&gt;
&lt;p&gt;If you take a look at the example in that blog you might notice the datasource is set to the service URL. This is because the grid itself will use a igDataSource control to bind to data and as such it is available for you as well. If you want to tweak some of its setting you can define your data source like so:&lt;/p&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c1740a1d-78a2-46b0-9430-51129a30e5d9" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#ddd;max-height:400px;overflow:auto;"&gt;
&lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; oDataInJson = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; $.ig.JSONPDataSource(&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ dataSource: &lt;span style="color:#800000;"&gt;&amp;#39;http://services.odata.org/OData/OData.svc/Categories?$format=json&amp;amp;$callback=?&amp;#39;&lt;/span&gt;, &lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;responseDataKey: &lt;span style="color:#800000;"&gt;&amp;quot;d&amp;quot;&lt;/span&gt; &lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can read more about this control in our&amp;nbsp; &lt;a title="Help topics on the Infragistics jQuery-based data source control." href="http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=igDataSource_igDataSource.html" target="_blank"&gt;Help Topics&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;Load On Demand with ASP.NET MVC&lt;/h1&gt;
&lt;p&gt;Unlike the majority of our jQuery products where the helpers mostly mirror the widget&amp;rsquo;s settings and add some comforts for those used to writing in a managed environment, this time it&amp;rsquo;s different. As said above the igHierarchicalGrid MVC wrapper does have a Load On Demand property. When that is set to true the wrapper provides utility to send&amp;nbsp; responses to the client in JSON format. To be more specific it is the grid&amp;rsquo;s model that provides the support for that. There&amp;rsquo;s a catch though &amp;ndash; the responses use the model&amp;rsquo;s GetData() method and&amp;nbsp; that means the model is needed wherever those responses are created, which makes setting up the grid in the View with chaining syntax something you might want to avoid. The model of the grid along with all the properties should be then defined in either the Controller of the Model. There is also one more thing to note &amp;ndash; the model creating is best done in a separate method and here&amp;rsquo;s the full code for one:&lt;/p&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:aa8444fb-4d1f-4564-9850-ad11fe0c4383" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#fff;max-height:400px;overflow:auto;"&gt;
&lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; Infragistics.Web.Mvc;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:20a6b3cc-192b-43ea-8e13-89c364ed1a6f" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#ddd;max-height:300px;overflow:auto;"&gt;
&lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridModel&lt;/span&gt; CreateGridModel()&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridModel&lt;/span&gt; grid = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridModel&lt;/span&gt;();&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;// Set up properties and columns:&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.AutoGenerateColumns = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.Columns = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;&amp;gt;();&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.Columns.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Customer&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;CustomerID&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;string&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;300px&amp;quot;&lt;/span&gt;));&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.Columns.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Company Name&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;CompanyName&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;string&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;150px&amp;quot;&lt;/span&gt;));&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.Columns.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Country&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;Country&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;string&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;150px&amp;quot;&lt;/span&gt;));&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.PrimaryKey = &lt;span style="color:#a31515;"&gt;&amp;quot;CustomerID&amp;quot;&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.AutoGenerateLayouts = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;// Create child layout&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridColumnLayoutModel&lt;/span&gt; layout = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumnLayoutModel&lt;/span&gt;();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.Key = &lt;span style="color:#a31515;"&gt;&amp;quot;Orders&amp;quot;&lt;/span&gt;;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.ForeignKey = &lt;span style="color:#a31515;"&gt;&amp;quot;CustomerID&amp;quot;&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.PrimaryKey = &lt;span style="color:#a31515;"&gt;&amp;quot;OrderID&amp;quot;&lt;/span&gt;;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.AutoGenerateColumns = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.Columns = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;&amp;gt;();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.Columns.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Order ID&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;OrderID&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;number&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;100px&amp;quot;&lt;/span&gt;));&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.Columns.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Customer&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;CustomerID&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;string&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;100px&amp;quot;&lt;/span&gt;));&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.Columns.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Order Date&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;OrderDate&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;150px&amp;quot;&lt;/span&gt;));&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.Columns.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridColumn&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Shipped Date&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;ShippedDate&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;150px&amp;quot;&lt;/span&gt;));&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;// Add paging to child layouts (different from the parent&amp;#39;s)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridPaging&lt;/span&gt; layoutPaging = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridPaging&lt;/span&gt;();&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layoutPaging.VisiblePageCount = 2;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layoutPaging.PageSize = 5;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layoutPaging.Type = &lt;span style="color:#2b91af;"&gt;OpType&lt;/span&gt;.Remote;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.Features.Add(layoutPaging);&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//add that layout to the grid&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.ColumnLayouts.Add(layout);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//most importantly turn Load On demand on and define response Urls:&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.LoadOnDemand = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.DataSourceUrl = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Url.Action(&lt;span style="color:#a31515;"&gt;&amp;quot;BindParent&amp;quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.ColumnLayouts[0].DataSourceUrl = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Url.Action(&lt;span style="color:#a31515;"&gt;&amp;quot;BindChild&amp;quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//Also add paging to the parent layout&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridPaging&lt;/span&gt; paging = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridPaging&lt;/span&gt;();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;paging.VisiblePageCount = 2;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;paging.PageSize = 10;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;paging.Type = &lt;span style="color:#2b91af;"&gt;OpType&lt;/span&gt;.Remote;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.Features.Add(paging);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;// Return the finished model&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; grid;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You will have to scroll down a bit to get to the part we are interested in &amp;ndash; starting at line 39 where the LoadOnDemand property is set to true. The layouts had to be created before that so data source URL-s can now be assigned to them. &lt;/p&gt;
&lt;p&gt;Now back to the subject of JSON responses as seen above we have defined a grid model with two levels of hierarchy &amp;ndash; a parent entries with child entries. Therefore we have the &amp;ldquo;BindParent&amp;rdquo; and &amp;ldquo;BindChild&amp;rdquo; as seen above. A very important note to take is that such a response is required for each layout, so one method returning requested data for each level in your data. As mentioned those methods would use the model&amp;rsquo;s GetData(), this is why we moved its creation to a separate method, because it is used to pass the model to the view and in all of those methods as well. Their return type should be JsonResult as that is what the grid would expect, but you don&amp;rsquo;t have to worry about converting data yourself. This is how those look:&lt;/p&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:71011fc1-3437-4085-be32-69f58d1a35f7" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#ddd;max-height:400px;overflow:auto;"&gt;
&lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JsonResult&lt;/span&gt; BindParent()&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//create a model&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridModel&lt;/span&gt; grid = CreateGridModel();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//set its datasource&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; dataContext = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;NorthwindDataContext&lt;/span&gt;();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; dataSource = dataContext.Customers;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.DataSource = dataSource.Take(30);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//and use the GetData() method to return the results&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; grid.GetData();&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And then you have the one for the child layout:&lt;/p&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:89bb0e5f-24d0-4a62-8886-c3d82d96dde8" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#ddd;max-height:400px;overflow:auto;"&gt;
&lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JsonResult&lt;/span&gt; BindChild(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; path, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; layout)&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//create a model&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridModel&lt;/span&gt; grid = CreateGridModel();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//set its datasource&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; dataContext = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;NorthwindDataContext&lt;/span&gt;();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; dataSource = dataContext.Orders;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;grid.DataSource = dataSource;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;//and use the GetData() method to return the results&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; grid.GetData(path, layout);&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Notice we never defined data source in the model creation method and also notice the response methods set that to the proper table for each layout. Notice as well that the parent requires no parameters &amp;ndash; this is based on the way the grid performs internal requests. Parameters guide the method on which layout should the data be set and also its path in the hierarchy. The general path format would describe the sequence in which rows were expanded like so:&lt;/p&gt;
&lt;p&gt;PrimaryKeyID/ChildPrimaryKeyID/AnotherChildKey[layout name]. &lt;/p&gt;
&lt;p&gt;Based on how your grid/data is set up any of the expanded rows&amp;rsquo; keys in the path can go with a layout name if it is specific to it. In the case above that would mean the PrimaryKeyID would be the guide for the children under that specific row in the parent, then from them the children of the ChildPrimaryKeyID row and then the specific child layout under AnotherChildKey from the latter. This might seem somewhat confusing but take it like this &amp;ndash; it is true to its name &amp;ndash; you start from the root (notice it is not mentioned in the path) move down the keys following the hierarchy to get to required data. Now the path above is for 4 levels of hierarchy and since the example so far is just two we only get the first part in the path &amp;ndash; the PrimaryKeyID which would be the id of the expanded parent row and look like:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.infragistics.com/community/Release/11.2/JQUERY/Hierarchical_Grid-Load_On_Demand/jQuery-Hierarchical-Grid_Load-on-Demand-path.png" title="jQuery Hierarchical Grid Load on demand request path." alt="jQuery Hierarchical Grid Load on demand request path." /&gt;&lt;/p&gt;
&lt;p&gt;And as you may have already guessed an request with empty path would mean the parent level, thus the BindParent takes zero arguments. &lt;/p&gt;
&lt;h1&gt;Events&lt;/h1&gt;
&lt;p&gt;The jQuery Hierarchical Grid offers two events related to Load On Demand. You can start by reading a blog written by Jordan Tsankov on just that &amp;ndash; &lt;a title="A blog on Handling Events in the jQuery Hierarchical Grid" href="http://blogs.infragistics.com/blogs/jordan_tsankov/archive/2012/01/30/jquery-hierarchical-grid-handling-events.aspx" target="_blank"&gt;Handling Events in the igHierarchicalGrid&lt;/a&gt;. The basic principals on using the LoadOnDemand events is just the same as using rowExpanding or rowCollapsed you can see in that blog. The widget will fire two events consequently upon loading requested data &amp;ndash; first &amp;lsquo;childrenPopulating&amp;rsquo; and then the standard &amp;lsquo;childrenPopulat&lt;strong&gt;ed&lt;/strong&gt;&amp;rsquo;. As always the &amp;lsquo;-ing&amp;rsquo; even fires as child layout is just about to be populated with data and is cancellable, while the other event is fired after the population is complete and is not cancellable. Following the convention you can hook up an event handler by just using the name of the control plus the name of the event without further complications like so:&lt;/p&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:12f8d570-444e-42e2-9745-103efb929672" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#ddd;max-height:400px;overflow:auto;"&gt;
&lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt;
&lt;li&gt;$(&lt;span style="color:#800000;"&gt;&amp;quot;#hierarchicalGrid&amp;quot;&lt;/span&gt;).live(&lt;span style="color:#800000;"&gt;&amp;quot;ighierarchicalgridchildrenpopulating&amp;quot;&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt; (evt, args) {&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#006400;"&gt;//you can decline loading data for certain rows, like some that may not even have child items&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#006400;"&gt;//calcel out if calling row with key ID of 0&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (args.id == &lt;span style="color:#800000;"&gt;&amp;quot;ID:0&amp;quot;&lt;/span&gt;)&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;}&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#006400;"&gt;//define you own logic to hanle the event&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;});&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As you can find in our &lt;a title="Hierarchical jQuery Grid control API" href="http://help.infragistics.com/jQuery/2011.2/ui.ighierarchicalgrid" target="_blank"&gt;API&lt;/a&gt; and in Jordan&amp;rsquo;s blog above you have access to plenty of information about the event and the participants and for the sake of keeping it simple the example above just uses the special ID formed by the row&amp;rsquo;s primary key and its value to check if the event has been fired while activating load on demand from the very first row. The demo for this project includes event logging for both MVC and OData implementations, so you can check that one out.&lt;/p&gt;
&lt;h1&gt;The Added benefits&lt;/h1&gt;
&lt;p&gt;If you remember from the introduction enabling load on demand would also lay foundations for other remote functionalities. You probably have figured it out the moment OData was mentioned &amp;ndash; the protocol providers support those features and the grid will make the appropriate requests when remote paging, filtering, sorting and even summaries!&lt;/p&gt;
&lt;p&gt;Then there is even more! The MVC wrapper being witty and all will not only parse and execute hierarchical data requests. It is also capable of querying data based on other options it recognizes in the grid&amp;rsquo;s request &amp;ndash; which means that you simply instruct the grid to perform remote those actions and it will create the appropriate requests and the getData() method will return the correct rows. It really is that simple, you define options, set them to remote and don&amp;rsquo;t even bother setting up URL key(s) for filtering or sorting like you are normally required to. Here&amp;rsquo;s what you can &lt;strong&gt;&lt;em&gt;simply add&lt;/em&gt;&lt;/strong&gt; to the CreateModel method from above:&lt;/p&gt;
&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f2b10d2f-9448-47ca-8dd1-9dc3a3e284ca" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background:#ddd;max-height:400px;overflow:auto;"&gt;
&lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#008000;"&gt;//Add features:&lt;/span&gt;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridSorting&lt;/span&gt; sorting = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridSorting&lt;/span&gt;();&lt;/li&gt;
&lt;li&gt;&amp;nbsp;sorting.Type = &lt;span style="color:#2b91af;"&gt;OpType&lt;/span&gt;.Remote;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;grid.Features.Add(sorting);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridPaging&lt;/span&gt; paging = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridPaging&lt;/span&gt;();&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;paging.PageSize = 10;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;paging.Type = &lt;span style="color:#2b91af;"&gt;OpType&lt;/span&gt;.Remote;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;grid.Features.Add(paging);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;GridFiltering&lt;/span&gt; filtering = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;GridFiltering&lt;/span&gt;();&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;filtering.Type = &lt;span style="color:#2b91af;"&gt;OpType&lt;/span&gt;.Remote;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;filtering.Mode = &lt;span style="color:#2b91af;"&gt;FilterMode&lt;/span&gt;.Simple;&lt;/li&gt;
&lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;grid.Features.Add(filtering);&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;The Load on Demand functionality of the NetAdvantage for jQuery Hierarchical Grid will keep it simple and reward with great results. Should you choose to expose your data via the Open Data Protocol (OData), your client-side implementation of the control will readily take advantage of all it can offer and handle the requests for you with little to no extra effort. And if you prefer different approach the wrapper will assist you greatly in enabling such functionality on your server-side as well as once more managing requests and generating proper responses. And while doing that Load On Demand would also become available for a number of features that can be performed remotely such as paging, summaries, sorting and filtering.&lt;/p&gt;
&lt;p&gt;A read you might find interesting in our help topics would be the &lt;a title="Getting started with igGrid, oData and WCF Data Services guide" href="http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=igGrid_Getting_Started_With_igGrid_oData_and_WCF_Data_Services.html" target="_blank"&gt;Getting started with igGrid, oData and WCF Data Services&lt;/a&gt; guide in our Help Topics which is another way you can consume OData with your grid.&lt;/p&gt;
&lt;p&gt;Also head over to our &lt;a title="jQuery Hierarchical Grid Sample" href="http://samples.infragistics.com/jquery/hierarchical-grid/hierarchical-grid-load-on-demand" target="_blank"&gt;Samples&lt;/a&gt; to try it out and you can also download the &lt;a title="Hierarchical Grid Load on demand Demo project." href="http://media.infragistics.com/community/Release/11.2/JQUERY/Hierarchical_Grid-Load_On_Demand/load-on-demand_Demo.zip" target="_blank"&gt;Demo project&lt;/a&gt; accompanying this blog in which you will find implemented ASP.NET MVC using the wrapper and a pure jQuery / JavaScript implementation consuming OData.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.infragistics.com/community/aggbug.aspx?PostID=332605" width="1" height="1"&gt;</description><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Razor/default.aspx">Razor</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/NetAdvantage+for+jQuery/default.aspx">NetAdvantage for jQuery</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/NetAdvantage/default.aspx">NetAdvantage</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/APS.NET+MVC/default.aspx">APS.NET MVC</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/CSS3/default.aspx">CSS3</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/MVC/default.aspx">MVC</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/CDN/default.aspx">CDN</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Infragistics/default.aspx">Infragistics</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/11.2/default.aspx">11.2</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Grid/default.aspx">Grid</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Filter/default.aspx">Filter</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/igGrid/default.aspx">igGrid</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Hierarchical+Grid/default.aspx">Hierarchical Grid</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Hierarchical/default.aspx">Hierarchical</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Load/default.aspx">Load</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Load+On+Demand/default.aspx">Load On Demand</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/OData/default.aspx">OData</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/Demand/default.aspx">Demand</category><category domain="http://www.infragistics.com/community/blogs/damyan_petev/archive/tags/igHierarchicalGrid/default.aspx">igHierarchicalGrid</category></item></channel></rss>