Search results matching tag 'OData'http://community.infragistics.com/search/SearchResults.aspx?a=1&o=DateDescending&tag=OData&orTags=0Search results matching tag 'OData'en-USCommunityServer 2008.5 SP1 (Build: 31106.3070)Tips on Drag &amp; Drop with the Ignite UI Treehttp://community.infragistics.com/blogs/damyan_petev/archive/2012/12/19/tips-on-drag-amp-drop-with-the-ignite-ui-tree.aspxWed, 19 Dec 2012 17:23:00 GMT7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:386139dpetev<p><img title="Tips on Drag &amp; Drop with the Ignite UI Tree" style="float:left;margin:0px 5px 0px 0px;display:inline;" alt="Tips on Drag &amp; Drop with the Ignite UI Tree" align="left" src="http://media.infragistics.com/community/Release/12.2/jQuery/Tree-Drag-Drop/ignite-ui-tips-tree-drag-drop.png" />As promised in the previous blog on <a title="Ignite UI Tree Drag &amp; Drop" href="http://www.infragistics.com/community/blogs/damyan_petev/archive/2012/12/13/ignite-ui-tree-drag-and-drop.aspx" target="_blank">Drag &amp; Drop with the Ignite UI Tree</a> – some tips and tricks coming right up. If you haven’t already looked into the control’s features, now’s your chance – overview with main ones listed in the <a title="igTree Overview - Ignite UI&trade; Online Help :: 2012.2" href="http://help.infragistics.com/NetAdvantage/jQuery/2012.2/CLR4.0?page=igTree_Overview.html" target="_blank">Documentation</a> and <a title="Ignite UI online samples - jQuery Tree" href="http://www.infragistics.com/products/jquery/tree" target="_blank">live in the Samples</a>. Looking at those, while each of them is rather nice, how do you think some of them would work alongside each other…and is something missing? The first one is always a potential trouble maker and the latter.. well extending functionality is fun, but as you know there are always new stuff coming with each release – might be just the thing you are missing. We do take feedback on everything through socials (links always below), there’s an active community at the <a title="Forums &raquo; IgniteUI - jQuery Controls" href="http://www.infragistics.com/community/forums/default.aspx?GroupID=80" target="_blank">Forums</a> and you can always <a title="Feature Request" href="https://www.infragistics.com/my-account/feature-request/" target="_blank">submit a feature request( must be logged in)</a>. Enough with the shameless plugs, on to the discussion!</p> <h1>Play nice?</h1> <p>As you’ve already seen in my previous post there are some quirks for example when you have nodes moving around with Drag and Drop and <strong>checkboxes</strong> at the same time you will loose the checkbox state and when a tri-state parent is fully checked a dropped node will respect the valid-for-all rule. </p> <p>It’s merely the fact that while drag and drop is a nice interaction from a user standpoint, underneath it involves removing and adding nodes. While that is simple in itself, it does present a number of situations where it can be really tricky to preserve whatever state the node may have applied by multiple other features. There’s a similar scenario with <strong><a title="Tree Selection - Ignite UI Online Samples" href="http://www.infragistics.com/products/jquery/sample/tree/selection">selection</a></strong> when you move the selected node around – you still keep the selection data, but the visual is gone as the node is re-created.</p> <p>Then you have another <a title="Tree Load on Demand - Ignite UI Online Samples" href="http://www.infragistics.com/products/jquery/sample/tree/load-on-demand">major feature of the Ignite UI Tree – the Load On Demand</a>. This is an extra tricky one actually. While the moving of nodes happens entirely on the client and there’s little that can come in it’s way.. it’s really hard to add a node to a parent one that hasn’t yet populated its children. Yes, you can easily supply the UI, but the underlying data source would still contain no array of child items for you to add to. Of course, one the node populates it’s all good and cool, but as you get told everywhere users are notoriously impatient and in case they do not wait for the node to load it can get quite messy.</p> <p>Do keep in mind thought, the Ignite UI toolset keeps evolving with not only new features, but general improvements as well and it’s certain Drag&amp;Drop will become more in tune with the rest. For that reason, what I do provide for now would possible become obsolete, but it’s more of a testimony&nbsp; to the fact that you can <strong>enhance and extend</strong> Ignite UI controls with very <strong>little effort</strong>!</p> <h1>Play nice.. or I’ll make you!</h1> <p>So let’s get on with the modifications. The Tree’s events will be our heroes of the day as many if not all major changes are represented with them. I have one very easy fix for maintaining proper selection UI with truly minor effort – as I said it’s all really a matter of picking the right time to hook your code. I figured it’s mildly pointless to update a second selection variable on each change, so instead I will check when a drag is starting if the node in question is selected. Then when the said node is dropped I would simply use the API method provided for selection. This will in essence go and set in the new path for the node:</p> <p> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b016fcb-b36f-416d-a2b0-89982c66aa25" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"> <div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;"> <div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"><span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">var</span><span style="background:#ffffff;color:#000000;"> selectionDirty = </span><span style="background:#ffffff;color:#0000ff;">false</span><span style="background:#ffffff;color:#000000;">;</span></div> </div> </div></p> <p> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f6f84add-5272-4ed4-8c46-642899b39d93" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"> <div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;"> <div style="background:#ddd;max-height:300px;overflow:auto;"> <ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"> <li><span style="background:#ffffff;color:#000000;">$(</span><span style="background:#ffffff;color:#a31515;">&#39;#tree&#39;</span><span style="background:#ffffff;color:#000000;">).igTree({</span></li> <li> <span style="background:#ffffff;color:#000000;">dragAndDrop: </span><span style="background:#ffffff;color:#0000ff;">true</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">dragAndDropSettings: {</span></li> <li> <span style="background:#ffffff;color:#000000;">dragAndDropMode: </span><span style="background:#ffffff;color:#a31515;">&#39;default&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">dragStartDelay: 100,</span></li> <li> <span style="background:#ffffff;color:#000000;">revert: </span><span style="background:#ffffff;color:#0000ff;">true</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">//simple icon-only tooltip </span></li> <li> <span style="background:#ffffff;color:#000000;">invalidMoveToMarkup: </span><span style="background:#ffffff;color:#a31515;">&#39;&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&#39;</span><span style="background:#ffffff;color:#000000;">, </span></li> <li> <span style="background:#ffffff;color:#000000;">containment: $(</span><span style="background:#ffffff;color:#a31515;">&quot;#tree&quot;</span><span style="background:#ffffff;color:#000000;">)</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">dragStart: </span><span style="background:#ffffff;color:#0000ff;">function</span><span style="background:#ffffff;color:#000000;"> (evt, ui) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// check if element is the one selected</span></li> <li> <span style="background:#ffffff;color:#000000;">selectionDirty = $(</span><span style="background:#ffffff;color:#a31515;">&#39;#tree&#39;</span><span style="background:#ffffff;color:#000000;">).igTree(</span><span style="background:#ffffff;color:#a31515;">&#39;isSelected&#39;</span><span style="background:#ffffff;color:#000000;">, ui.element);</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">nodeDropped: </span><span style="background:#ffffff;color:#0000ff;">function</span><span style="background:#ffffff;color:#000000;">(evt, ui) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">if</span><span style="background:#ffffff;color:#000000;"> (selectionDirty) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">//if it was selected, re-select when dropped in new place</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">var</span><span style="background:#ffffff;color:#000000;"> newNode = $(</span><span style="background:#ffffff;color:#a31515;">&quot;#tree&quot;</span><span style="background:#ffffff;color:#000000;">).igTree(</span><span style="background:#ffffff;color:#a31515;">&quot;nodeByPath&quot;</span><span style="background:#ffffff;color:#000000;">, ui.path + </span><span style="background:#ffffff;color:#a31515;">&#39;_&#39;</span><span style="background:#ffffff;color:#000000;"> + ui.draggable.attr(</span><span style="background:#ffffff;color:#a31515;">&#39;data-path&#39;</span><span style="background:#ffffff;color:#000000;">).split(</span><span style="background:#ffffff;color:#a31515;">&#39;_&#39;</span><span style="background:#ffffff;color:#000000;">).pop());</span></li> <li> <span style="background:#ffffff;color:#000000;">$(</span><span style="background:#ffffff;color:#a31515;">&#39;#tree&#39;</span><span style="background:#ffffff;color:#000000;">).igTree(</span><span style="background:#ffffff;color:#a31515;">&#39;select&#39;</span><span style="background:#ffffff;color:#000000;">, newNode);</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li> <span style="background:#ffffff;color:#000000;">selectionDirty = </span><span style="background:#ffffff;color:#0000ff;">false</span><span style="background:#ffffff;color:#000000;">;</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">dataSource: northwindCategories,</span></li> <li> <span style="background:#ffffff;color:#000000;">bindings: {</span></li> <li> <span style="background:#ffffff;color:#000000;">textKey: </span><span style="background:#ffffff;color:#a31515;">&#39;CategoryName&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">primaryKey: </span><span style="background:#ffffff;color:#a31515;">&#39;CategoryID&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">valueKey: </span><span style="background:#ffffff;color:#a31515;">&#39;CategoryID&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">childDataProperty: </span><span style="background:#ffffff;color:#a31515;">&#39;Products&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">bindings: {</span></li> <li> <span style="background:#ffffff;color:#000000;">textKey: </span><span style="background:#ffffff;color:#a31515;">&#39;ProductName&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">valueKey: </span><span style="background:#ffffff;color:#a31515;">&#39;ProductID&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">primaryKey: </span><span style="background:#ffffff;color:#a31515;">&#39;ProductID&#39;</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li><span style="background:#ffffff;color:#000000;">});</span></li> </ol> </div> </div> </div></p> <p>The difference from what you have seen before as code for the tree are the dragStart and nodeDropped events. Because those come in line of the <a title="jQuery UI Interactions" href="http://api.jqueryui.com/category/interactions/">jQuery UI Draggable &amp; Droppable</a> events and they can generally handle interaction between two trees, you won’t see the familiar ‘ui.owner‘ to access the tree as it’s kind of hard to tell which tree should be an owner really :) However, since I’m adding handlers separately that’s okay – I know which tree to call. Also, the tree is helpful enough to give nodes by paths – the latter you can get by combining the event provided path (the parent one) and the ID of the dropped element. The way this handles it right now should be suitable for deeper hierarchy that two as well.</p> <p>Note: Remember you have the same event arguments as in jQuery UI in addition to the Tree adding some stuff (the element for example), but in the case of the drop the element is the actual target and the draggable from the original arguments is the node being dropped. The results:</p> <p><img title="An (very low quality) animation to show the comparison between the default selection handling and the enhanced one." alt="An (very low quality) animation to show the comparison between the default selection handling and the enhanced one." src="http://media.infragistics.com/community/Release/12.2/jQuery/Tree-Drag-Drop/ignite-ui-tree-drag-drop-selection.gif" /></p> <p>You can take a very similar approach with the checkboxes in bi-state mode Trees to complement that feature, however, the tri-state limitation I feel might be the right design (respecting the parent global state). Up to you really, the option is there.</p> <h3>Load on Demand</h3> <p>As I mentioned it’s nothing that complicated stopping this from being flawless, except the very nature of loading data on demand..it’s not there yet! And if the user doesn’t want to wait things go bad. One very simple way is to decrease the expand delay (time till nodes automatically expand when dragged over) to mere nothing. This might make it work just fine if the service you use is fast enough to get ahead of the unsuspecting user. However, go too low and you risk the user triggering a whole bunch of requests on the drag path and actually making the application slower rather than faster. The solution lies in not letting the user drop on non-populated node. However, that would mean that at some point the node would expand and drop would be possible, but the helper will still be showing invalid location. It’s not such a nice experience to make the user shake the node around to force a drag and re-evaluation of the drop target. If you want just the perfect experience, you can have it with one trick – move the mouse for the user! Yup, basically listen for when the node is populated, check if the user is on top of it, and trigger a mouse move so the validation will be re-done:</p> <p> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8f015cc3-6916-4e15-8f1d-59549962b0dc" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"> <div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;"> <div style="background:#ddd;max-height:300px;overflow:auto;"> <ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"> <li><span style="background:#ffffff;color:#000000;"> </span><span style="background:#ffffff;color:#0000ff;">var</span><span style="background:#ffffff;color:#000000;"> stateHelper = { dropTarget: </span><span style="background:#ffffff;color:#0000ff;">null</span><span style="background:#ffffff;color:#000000;">, populatingNode: </span><span style="background:#ffffff;color:#0000ff;">null</span><span style="background:#ffffff;color:#000000;">, draggedNode: </span><span style="background:#ffffff;color:#0000ff;">null</span><span style="background:#ffffff;color:#000000;"> };</span></li> </ol> </div> </div> </div> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e9a0182a-2ed0-48be-ae0d-b749d54a6136" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"> <div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;"> <div style="background:#ddd;max-height:300px;overflow:auto;"> <ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;white-space:nowrap;"> <li><span style="background:#ffffff;color:#000000;">$(</span><span style="background:#ffffff;color:#a31515;">&quot;#tree&quot;</span><span style="background:#ffffff;color:#000000;">).igTree({</span></li> <li> <span style="background:#ffffff;color:#000000;">dragAndDrop: </span><span style="background:#ffffff;color:#0000ff;">true</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">parentNodeImageClass: </span><span style="background:#ffffff;color:#a31515;">&quot;parent&quot;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">dragAndDropSettings: {</span></li> <li> <span style="background:#ffffff;color:#000000;">dragAndDropMode: </span><span style="background:#ffffff;color:#a31515;">&quot;move&quot;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">customDropValidation: </span><span style="background:#ffffff;color:#0000ff;">function</span><span style="background:#ffffff;color:#000000;"> (element) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// Validates the drop target:</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// Nodes will properly cause targets to expand (and therefore load)</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// But we must not allow actual drop before the data is loaded </span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// because we have nothing to add this node to.</span></li> <li> <span style="background:#ffffff;color:#000000;">stateHelper.dropTarget = $(</span><span style="background:#ffffff;color:#0000ff;">this</span><span style="background:#ffffff;color:#000000;">);</span></li> <li> <span style="background:#ffffff;color:#000000;">stateHelper.draggedNode = $(element);</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">var</span><span style="background:#ffffff;color:#000000;"> childNodes = stateHelper.dropTarget.closest(</span><span style="background:#ffffff;color:#a31515;">&#39;li[data-role=node]&#39;</span><span style="background:#ffffff;color:#000000;">).children(</span><span style="background:#ffffff;color:#a31515;">&#39;ul&#39;</span><span style="background:#ffffff;color:#000000;">);</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">if</span><span style="background:#ffffff;color:#000000;"> (childNodes.length &gt; 0 &amp;&amp; JSON.parse(childNodes.attr(</span><span style="background:#ffffff;color:#a31515;">&#39;data-populated&#39;</span><span style="background:#ffffff;color:#000000;">)) === </span><span style="background:#ffffff;color:#0000ff;">false</span><span style="background:#ffffff;color:#000000;">) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">return</span><span style="background:#ffffff;color:#000000;"> </span><span style="background:#ffffff;color:#0000ff;">false</span><span style="background:#ffffff;color:#000000;">;</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li>&nbsp;</li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">return</span><span style="background:#ffffff;color:#000000;"> </span><span style="background:#ffffff;color:#0000ff;">true</span><span style="background:#ffffff;color:#000000;">;</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">expandDelay: 500</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">dragStop: </span><span style="background:#ffffff;color:#0000ff;">function</span><span style="background:#ffffff;color:#000000;">(evt, ui) {</span></li> <li> <span style="background:#ffffff;color:#000000;">stateHelper.dropTarget = undefined;</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">nodePopulated: </span><span style="background:#ffffff;color:#0000ff;">function</span><span style="background:#ffffff;color:#000000;">(evt, ui) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">if</span><span style="background:#ffffff;color:#000000;"> (stateHelper.dropTarget &amp;&amp; $.contains(ui.element, stateHelper.dropTarget)) {</span></li> <li> <span style="background:#ffffff;color:#000000;">stateHelper.populatingNode = ui.element;</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">rendered: </span><span style="background:#ffffff;color:#0000ff;">function</span><span style="background:#ffffff;color:#000000;">(evt, ui) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">if</span><span style="background:#ffffff;color:#000000;"> (stateHelper.populatingNode) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// forse re-handling of the drag in case the user manages to </span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// shomehow keep his mouse steady when the node expands</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// this will evaluate the target again</span></li> <li> <span style="background:#ffffff;color:#000000;">stateHelper.populatingNode.children(</span><span style="background:#ffffff;color:#a31515;">&#39;a&#39;</span><span style="background:#ffffff;color:#000000;">).trigger({</span></li> <li> <span style="background:#ffffff;color:#000000;">type: </span><span style="background:#ffffff;color:#a31515;">&#39;mousemove&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">pageX: stateHelper.draggedNode.data(</span><span style="background:#ffffff;color:#a31515;">&#39;draggable&#39;</span><span style="background:#ffffff;color:#000000;">).position.left,</span></li> <li> <span style="background:#ffffff;color:#000000;">pageY: stateHelper.draggedNode.data(</span><span style="background:#ffffff;color:#a31515;">&#39;draggable&#39;</span><span style="background:#ffffff;color:#000000;">).position.top</span></li> <li> <span style="background:#ffffff;color:#000000;">});</span></li> <li> <span style="background:#ffffff;color:#000000;">stateHelper.populatingNode = undefined;</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li> <span style="background:#ffffff;color:#000000;">},</span></li> <li> <span style="background:#ffffff;color:#000000;">dataSourceType: </span><span style="background:#ffffff;color:#a31515;">&#39;remoteUrl&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">dataSource: </span><span style="background:#ffffff;color:#a31515;">&#39;http://services.odata.org/OData/OData.svc/Categories?$format=json&amp;$callback=?&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">responseDataKey: </span><span style="background:#ffffff;color:#a31515;">&quot;d&quot;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">loadOnDemand: </span><span style="background:#ffffff;color:#0000ff;">true</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">bindings: {</span></li> <li> <span style="background:#ffffff;color:#000000;">textKey: </span><span style="background:#ffffff;color:#a31515;">&#39;Name&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">valueKey: </span><span style="background:#ffffff;color:#a31515;">&#39;ID&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">primaryKey: </span><span style="background:#ffffff;color:#a31515;">&#39;ID&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">childDataProperty: </span><span style="background:#ffffff;color:#a31515;">&#39;Products&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">bindings: {</span></li> <li> <span style="background:#ffffff;color:#000000;">textKey: </span><span style="background:#ffffff;color:#a31515;">&#39;Name&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">valueKey: </span><span style="background:#ffffff;color:#a31515;">&#39;ID&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">primaryKey: </span><span style="background:#ffffff;color:#a31515;">&#39;ID&#39;</span><span style="background:#ffffff;color:#000000;">,</span></li> <li> <span style="background:#ffffff;color:#000000;">childDataProperty: </span><span style="background:#ffffff;color:#a31515;">&#39;Supplier&#39;</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li> <span style="background:#ffffff;color:#000000;">});</span></li> </ol> </div> </div> </div></p> <p>As you can see the Tree is bound to the oData Northwind service making calls only when needed, we listen for populated nodes and save them in the ‘stateHelper’ to later trigger the mouse move on them when the UI has been rendered.</p> <p><img title="A demonstation of how the experience can be improved with load on demand and Drag&amp;Drop" alt="A demonstation of how the experience can be improved with load on demand and Drag&amp;Drop" src="http://media.infragistics.com/community/Release/12.2/jQuery/Tree-Drag-Drop/drag-drop-load-on-demand.gif" /></p> <h3>A word on the custom validation function</h3> <p>The thing about this functions is that it will be overridden by the internal tree validation, which makes it the last last chance for you as a developer to return false and prevent a node drop on that target. What this also should tell you is that the internal validation will try to validate actual Ignite UI Tree as a target, so your function is not to enable something the feature won’t allow – no call will be made to it when the target is foreign. This begs the question, can you still use other targets? Yes, the drop events still fire on the drop targets! Take the <a title="Simple File Manager - Ignite UI samples" href="http://www.infragistics.com/products/jquery/sample/tree/simple-file-manager" target="_blank">Simple File Manager</a> as an example – the trick is in the usage of the droppable events instead!</p> <p> And as you have already seen form above the context of the function is the droppable element and the parameter is the draggable.</p> <p>Last but not least, if you are wondering how this JavaScript function is being used with the ASP.NET MVC wrappers, the MVC side property accepts a string with the function’s name. What that means is that such functions need to be discoverable on the global scope (on window really), so be careful where you define it:</p> <p> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8dcd4c16-8da9-423a-908c-0e534529eb9e" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"> <div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;"> <div style="background:#ddd;max-height:300px;overflow:auto;"> <ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"> <li><span style="background:#ffffff;color:#000000;"> </span><span style="background:#ffffff;color:#008000;">//rest is omitted</span></li> <li> <span style="background:#ffffff;color:#000000;">}).DragAndDropSettings(d =&gt;</span></li> <li> <span style="background:#ffffff;color:#000000;">{</span></li> <li> <span style="background:#ffffff;color:#000000;">d.ExpandDelay(500);</span></li> <li> <span style="background:#ffffff;color:#000000;">d.CustomDropValidation(</span><span style="background:#ffffff;color:#a31515;">&quot;customValidation&quot;</span><span style="background:#ffffff;color:#000000;">);</span></li> <li> <span style="background:#ffffff;color:#000000;">})</span></li> </ol> </div> </div> </div></p> <p>And then:</p> <h1> <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f6d2fdd6-77fd-4f56-80c7-af2dddb81183" class="wlWriterEditableSmartContent" style="float:none;padding-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;"> <div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;"> <div style="background:#ddd;max-height:300px;overflow:auto;"> <ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"> <li><span style="background:#ffffff;color:#0000ff;">&lt;</span><span style="background:#ffffff;color:#800000;">script</span><span style="background:#ffffff;color:#0000ff;">&gt;</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#0000ff;">function</span><span style="background:#ffffff;color:#000000;"> customValidation(element) {</span></li> <li> <span style="background:#ffffff;color:#000000;"></span><span style="background:#ffffff;color:#008000;">// omitted</span></li> <li> <span style="background:#ffffff;color:#000000;">}</span></li> <li><span style="background:#ffffff;color:#0000ff;">&lt;/</span><span style="background:#ffffff;color:#800000;">script</span><span style="background:#ffffff;color:#0000ff;">&gt;</span></li> </ol> </div> </div> </div></h1> <h1>Resources</h1> <p>First let me again remind of the <a title="igTree Overview - Ignite UI&trade; Online Help :: 2012.2" href="http://help.infragistics.com/NetAdvantage/jQuery/2012.2/CLR4.0?page=igTree_Overview.html" target="_blank">elaborate Ignite UI Tree Documentation</a> and <a title="Ignite UI jQuery API Reference" href="http://help.infragistics.com/jQuery/2012.2/ui.igtree" target="_blank">jQuery API Reference</a>. Then don’t forget the <strong><a title="Ignite UI Tree samples" href="http://www.infragistics.com/products/jquery/tree" target="_blank">awesome samples</a>! </strong></p> <p>This time I’ll add in the mix a <a title="ASP.NET MVC demo project for the Ignite UI Tree&#39;s Drag and Drop feature" href="http://media.infragistics.com/community/Release/12.2/jQuery/Tree-Drag-Drop/tree-drag-drop-tips.zip" target="_blank">solid ASP.NET MVC demo project</a> ( with everything from here included in with both MVC helper and script-only demos, plus some basic stuff from the previous post). <strong>Make sure to check that one out, the animations above don’t do it justice!</strong>&nbsp; You would need at least a trial version of Ignite UI so hit the banner below if you are still lacking one.</p> <p>Also you can go for fiddling with two demos on JSFiddle:</p> <ul> <li><a title="Ignite Ui Tree: Basic settings and events + enhanced selection demo on JSFiddle" href="http://jsfiddle.net/damyanpetev/TZXP2/" target="_blank">Basic settings and events + enhanced selection demo</a></li> <li><a title="Ignite UI Tree: Modified Drag&amp;Drop + Load On Demand behavior with Custom drop validation function on JSFiddle." href="http://jsfiddle.net/damyanpetev/uLxax/" target="_blank">Modified Drag&amp;Drop + Load On Demand behavior with Custom drop validation function.</a></li></ul> <p><strong>Stay tuned,</strong> for there is still more awesome tricks I have for you – next time we’ll do some updating support!</p> <h1>Summary</h1> <p>This was the second part of the in-depth look at the Ignite UI Tree’s Drag and Drop feature. We covered some of the challenges such functionality presents and how you can overcome them. We improved the selection handling of moved nodes, we made the experience a true joy with Load on Demand. We also gave a little attention to the custom validation function – what is it for, what to expect and what you can do with it. At the end of this, I would like to remind you that this has been a proof of the concept that the controls are flexible enough to let you mold them to your needs with little code and great impact!</p> <p name="gotcha"><a title="Donwload your Ignite UI Free Trial now!" href="http://www.infragistics.com/products/jquery/downloads" target="_blank"><img title="Donwload your Ignite UI Free Trial now!" alt="Donwload your Ignite UI Free Trial now!" src="http://media.infragistics.com/community/Release/12.2/jQuery/IgniteUI-download.jpg" /></a></p> <p name="gotcha"><em>And as always, you can follow us on Twitter </em><a title="That would be me!" href="https://twitter.com/DamyanPetev"><em>@DamyanPetev</em></a><em> and </em><a title="Infragistics on Twitter" href="https://twitter.com/infragistics" target="_blank"><em>@Infragistics</em></a><em> and stay in touch on </em><a title="Infragistics on Facebook" href="http://www.facebook.com/infragistics" target="_blank"><em>Facebook</em></a><em>, </em><a title="Infragistics on Google+" href="https://plus.google.com/110651137371189140377" target="_blank"><em>Google+</em></a><em> and </em><a title="Infragistics on LinkedIn" href="http://www.linkedin.com/company/16069" target="_blank"><em>LinkedIn</em></a><em>! </em></p>Introducing ReportPlus: Building Enterprise Dashboards on the iPadhttp://community.infragistics.com/blogs/gabriel-lopez/archive/2012/09/19/introducing-reportplus-building-enterprise-dashboards-on-the-ipad.aspxWed, 19 Sep 2012 15:53:00 GMT7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:373374glopez@infragistics.com<p>A long time ago, in a galaxy far far away we set out to build a solution that would challenge in some way the current status quo in the <strong>mobile business intelligence</strong> segment that treats the <strong>iPad</strong> pretty much as a one-way, consuming only experience, as a second class citizen.</p>
<p>In a time where mobile devices are becoming more and more capable we tried to envision how any power user could generate business intelligence insights based only on his <strong>iPad</strong>, assuming availability of any of an array of popular enterprise technologies, and relying as little as possible on any IT intervention for his <a target="_blank" title="self service business intelligence" href="http://blogs.forrester.com/boris_evelson/12-06-12-self_service_bi">self service BI</a> journey to be a success.</p>
<p>Such a solution would enable anyone in the organization with an iPad, to be able to access LOB data, stored for instance in a <strong>SharePoint</strong> library, or a <strong>SQL Server</strong> database, or a <strong>Reporting Services</strong> report, even an <strong>Analysis Services</strong> cube, without the hassle of going through any additional server side setup or configuration. The premise is simple, if the user has clearance, then he should be able to <strong>access enterprise data from the iPad, no excuses.</strong></p>
<p>Additionally, this solution would allow him to <strong>filter &amp; pivot</strong> that information, customizing the way it&rsquo;s presented, allowing <strong>charting</strong> options, and composing all views in meaningful <strong>dashboards</strong>, that he could share. Since that authoring experience would be completely based on the iPad, all the interactions of the process would have to accommodate to a gesture based experience, so it should be a tap and drag driven interaction. The goal would be to provide<strong> the most simple, and easy to use user experience possible</strong>.</p>
<p>So we&rsquo;ve been working hard to make that vision a reality, and we are very pleased to announce that the result of that effort is already available for download. We call it <a target="_blank" title="ReportPlus: Mobile Business Intelligence Dashboards" href="http://pro.reportplus.com"><strong>ReportPlus</strong></a>, you can check it out in the <a title="ReportPlus: Mobile Business Intelligence Dashboards" href="http://pro.reportplus.com">iTunes app store</a>.</p>
<p style="text-align:center;"><img src="http://media.infragistics.com/community/images/craigs/blog/2012/reportplus-logo.png" alt="ReportPlus: Business Intelligence Dashboards" height="69" width="350" /></p>
<p>For more information, check this <a target="_blank" title="ReportPlus: Mobile Business Intelligence Dashboards" href="http://youtu.be/28ntjGQMg4Q">ReportPlus Introductory video</a>, and <a title="Craig&#39;s post on ReportPlus" href="http://www.infragistics.com/community/blogs/craig_shoemaker/archive/2012/09/19/ipad-you-enterprise-reporting.aspx">Craig&#39;s post on the subject</a>.</p>
<p></p> jQuery Mobile Controls by Infragisticshttp://community.infragistics.com/blogs/damyan_petev/archive/2012/05/18/infragistics-jquery-mobile-controls.aspxFri, 18 May 2012 14:33:00 GMT7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:351478dpetev<p>With the <a target="_blank" href="http://www.infragistics.com/dotnet/netadvantage/jquery-controls.aspx">jQuery product</a> Infragistics envisioned business intelligence and data visualization across a range of platforms, not just one &ndash; more like every single one of them. Built on popular and largely supported HTML5 and jQuery UI and striving to provide a comprehensive toolset for development of performant and stylish applications that are to run on every device regardless of the OS. On top of that &lsquo;mobile&#39; was a subtle, yet dominant theme across our product line with the latest release. Touch support and metro themes everywhere! But there&rsquo;s more to it &ndash; the jQuery UI is awesome and will run on just about any modern browser, yet it was not specifically designed for mobile devices, not until recently anyway! <a title="jQuery Mobile: Touch-Optimized Web Framework for Smartphones &amp; Tablets" href="http://jquerymobile.com/" target="_blank">jQuery&rsquo;s Mobile framework</a> is-&nbsp; still relatively fresh, but it is just what you might need &ndash; it&rsquo;s touch optimized, it&rsquo;s compatible with with most smartphones and tablets and other frameworks(like PhoneGap). It is designed to be lightweight and its UI controls designed for pocket-size pages and touch, but it&rsquo;s not limited to that, as mobile pages will scale to the screen so it would work and look just as good on a bigger tablet and even a desktop(check out their <a title="jQuery Mobile Demos and Docs" href="http://jquerymobile.com/demos/1.1.0/" target="_blank">demos</a> using nothing but the framework). As with JQuery UI, it&rsquo;s a strong cross-platform solution with a different perspective but the same goal &ndash; beautiful, powerful, universal solutions to your app problems. It sounds too good to miss, right? We thought so too&hellip;</p>
<h1>Enter the Infragistics jQuery Mobile controls </h1>
<p>With this release besides all controls taking on a touch-friendly nature, our NetAdvantage for jQuery family grew with specialized mobile controls leveraging the jQuery Mobile framework &ndash; the <a title="jQuery Mobile List View" href="http://www.infragistics.com/Control.aspx?id=22952#Overview" target="_blank">Mobile List View</a> and a mobile version of the <a title="jQuery Mobile Rating" href="http://www.infragistics.com/Control.aspx?id=22954#Overview" target="_blank">Rating</a>. As explained, with them the focus is on mobile-centric and gesture-friendly UI. That means optimizations for mobile devices for stuff like better content placement and some specific interactions along with touch support &ndash; larger UI elements to interact with and specialized events like tap hold, swipes, etc. </p>
<p><strong><em>The List view</em></strong></p>
<p>Sometimes for small screen devices like smartphone a full-fledged grid control would be somewhat hard to imagine and hardly optimal in terms of productivity. It&rsquo;s why mobile design, while trying to fit as much functionality in a limited space as possible, must not clutter or expect to fit everything in one page. This is why the mobile framework provides AJAX based navigation between pages (and by pages I mean their mobile version and multiples can very well exist in one html file). This is also where a control such as the list comes in play &ndash; think of it as the mobile version of the grid type control &ndash; it fits the environment well, it&rsquo;s easy to interact with, it can hold a lot of data and it can be hierarchical! The igListView is a widget that implements a hierarchical (nested) mobile list. Defining can be done in both in the well-known JavaScript/jQuery or using our ASP.NET (MVC) helpers. There&rsquo;s also a third method that is also the default method for the mobile framework &ndash; a pure markup definition that also has some plus sides. Settings are made via the HTML &ldquo;data-*&rdquo; attributes that are mostly for data storage and ignored by browsers when interpreting UI. So for a list you can simple define the standard UL and LI elements and if for some reason jQuery scripts fail to load or execute the browser would still have valid UI to render.</p>
<p>Now that approach wouldn&rsquo;t be very appropriate if you need some serious amount of data and the Infragistics Mobile ListView comes with a <span style="text-decoration:underline;">major data support enhancements</span>, one of which is <strong>templating</strong>. That means not just controlling the markup of each record but also defining a single UL-LI element and point the widget to data and it will template it appropriately. The other major additions to data handling:</p>
<ul>
<li>Search filtering with the added option of presets</li>
<li>Using the Infragistics Data Source means the controls can bind to a variety of sources</li>
<li>Sorting, sorting presets and groups separated with list deviders.</li>
<li>Load on Demand capabilities</li>
</ul>
<p><img title="Infragistics jQuery Mobile List View with grouping and iOS theme in the default c swatch." alt="Infragistics jQuery Mobile List View with grouping and iOS theme in the default c swatch." src="http://media.infragistics.com/community/Release/12.1/jQuery/Mobile_Controls/igListView_grouping_ios_default-c-swatch.png" /></p>
<p><strong><em>The Rating</em></strong></p>
<p>The mobile version of the rating control designed for touch means accuracy levels are restricted to whole numbers (or alternatively rounded to halves when the control is in read-only mode). The widget offers settings to control its layout along with getting and setting value, vote count and a changed value event along with the framework&rsquo;s touch-oriented ones. And as expected you can always tweak the items the rating is using to some other shape or color.</p>
<p><img title="Infragistics jQuery Mobile Rating with iOS theme in a swatch." alt="Infragistics jQuery Mobile Rating with iOS theme in a swatch." src="http://media.infragistics.com/community/Release/12.1/jQuery/Mobile_Controls/igRating_ios.png" /></p>
<p><strong><em>Style</em></strong></p>
<p>As you can tell by the screenshots above we&rsquo;ve designed a beautiful iOS style theme for our mobile controls. And for any of you familiar with jQuery UI you&rsquo;d expect a common and powerful themeing framework to be in play for mobile as well &ndash; and there is! Our theme will style all default <a href="http://www.infragistics.com">UI components</a> as well and it can be replaced with one of your own. And yes, there&rsquo;s a <a title="ThemeRoller for jQuery Mobile" href="http://jquerymobile.com/themeroller/" target="_blank">ThemeRoller for jQuery Mobile</a>! It&rsquo;s very easy to use &ndash; all mobile themes have 3 swatches that are usually used for default layouts and actions. Just like that our iOS theme has 3 swatches &ndash; a light C (default) swatch seen above with the list, darker B and the A swatch (the one with the exquisite fabric background above). I&rsquo;ve made a theme myself for what was like 10 min in a metro-style attempt and I&rsquo;ve included it in the demo just in case someone likes it:</p>
<p><img title="Infragistics jQuery Mobile List View with grouping and ThemeRoller built metro style theme." alt="Infragistics jQuery Mobile List View with grouping and ThemeRoller built metro style theme." src="http://media.infragistics.com/community/Release/12.1/jQuery/Mobile_Controls/igListView_grouping_metro.png" /></p>
<h1>A Mobile App</h1>
<p>Let&rsquo;s see how easy it can be to create a mobile app that is functional and stylish. We&rsquo;ll stay on the wave of new technology for the demo and create this app using the new mobile template in ASP.NET MVC 4! What would that do is it would lay all the basic layout of the app for you &ndash; referencing all jQuery scripts (mobile included) and styles, bundling and minifying them. It would also render your Views in the mobile version of a page by marking the content DIV with <em>data-role=&quot;page&quot;.</em>&nbsp; So all left to do is add the Infragistics Mobile Loader ask for the control you need and define it. For this demo I&rsquo;ll use Northwind again with two actions in the controller returning JSON serialized parts of it for an somewhat odd-styled manual load on demand scenario for the details of each list item (again this is different from the load on demand feature the igListView has which allows the end-user to request another portion of data to be loaded for his current list). Here&rsquo;s the snippet for the list:</p>
<p>&nbsp;</p>
<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:bb1f488b-e2f2-4a8f-903d-4fb953931604" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:300px;overflow:auto;"><ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;$.ig.loader({</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scriptPath: <span style="color:#800000;">&quot;../../Scripts/Infragistics-mobile/js/&quot;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cssPath: <span style="color:#800000;">&quot;../../Content/Infragistics-mobile/css/&quot;</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resources: <span style="color:#800000;">&quot;igmList.Filtering.Sorting&quot;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;theme: <span style="color:#800000;">&quot;</span><span style="background:#ffff00;color:#800000;">@</span>ViewBag.Theme<span style="color:#800000;">&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;});</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ul</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">=&quot;actionFedList&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-role</span><span style="color:#0000ff;">=&quot;iglistview&quot;</span></li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-auto-generate-layouts</span><span style="color:#0000ff;">=&quot;false&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-data-source</span><span style="color:#0000ff;">=&quot;/Home/Customers&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings-header-key</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> </li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings-primary-key</span><span style="color:#0000ff;">=&quot;CustomerID&quot;</span> </li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings-text-key</span><span style="color:#0000ff;">=&quot;Country&quot;</span></li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-auto-generate-layouts</span><span style="color:#0000ff;">=&quot;false&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-initial-data-bind-depth</span><span style="color:#0000ff;">=&quot;0&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings-details-title-key</span><span style="color:#0000ff;">=&quot;CustomerID&quot;</span></li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-sorting</span><span style="color:#0000ff;">=&quot;true&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-sorting-type</span><span style="color:#0000ff;">=&quot;local&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-sorting-auto-generate-sort-presets</span><span style="color:#0000ff;">=&quot;false&quot;</span> </li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-sorting-presets</span><span style="color:#0000ff;">=&#39;[ {&quot;text&quot;:&quot;Customer ID&quot;,&quot;sortedFields&quot;:[ {&quot;fieldName&quot;:&quot;CustomerID&quot;,&quot;direction&quot;:&quot;asc&quot;} ]}, {&quot;text&quot;:&quot;Contact Name&quot;,&quot;sortedFields&quot;:[ {&quot;fieldName&quot;:&quot;ContactName&quot;,&quot;direction&quot;:&quot;asc&quot;} ]}, {&quot;text&quot;:&quot;Country&quot;,&quot;showGrouping&quot;:&quot;true&quot;,&quot;sortedFields&quot;:[ {&quot;fieldName&quot;:&quot;Country&quot;,&quot;direction&quot;:&quot;asc&quot;} ]} ]&#39;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-filtering</span><span style="color:#0000ff;">=&quot;true&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-filtering-type</span><span style="color:#0000ff;">=&quot;local&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-filtering-search-bar-field-name</span><span style="color:#0000ff;">=&quot;ContactName,Country&quot;&gt;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">li</span><span style="color:#0000ff;">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ul</span> <span style="color:#ff0000;">data-role</span><span style="color:#0000ff;">=&quot;childLayout&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-auto-generate-layouts</span><span style="color:#0000ff;">=&quot;false&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-data-source</span><span style="color:#0000ff;">=&quot;/Home/Orders&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings</span><span style="color:#0000ff;">=&#39;{&quot;customerId&quot;:&quot;CustomerID&quot;}&#39;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-inset</span><span style="color:#0000ff;">=&quot;true&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-generate-compact-jsonresponse</span><span style="color:#0000ff;">=&quot;false&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings-count-key</span><span style="color:#0000ff;">=&quot;Freight&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-key</span><span style="color:#0000ff;">=&quot;CustomerID&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings-header-key</span><span style="color:#0000ff;">=&quot;OrderID&quot;</span> </li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">data-bindings-text-key</span><span style="color:#0000ff;">=&quot;ShipName&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">&gt;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ul</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">li</span><span style="color:#0000ff;">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ul</span><span style="color:#0000ff;">&gt;</span></li>
</ol></div>
</div>
</div>
<p>&nbsp;</p>
<p>Note i have my theme set using the MVC dynamic ViewBag and I choose (and let users choose) a theme and call the controller action with that theme. Since I can&rsquo;t put comments I&rsquo;ve grouped code to be easier to see which part does what. The magic combo here is <em>data-role=&quot;iglistview&rdquo;. </em>Also note the data source can be a link (it&rsquo;s the <a title="Infragistics jQuery Data Source Online Samples" href="http://samples.infragistics.com/jquery/data-source" target="_blank">igDataSource</a> after all) so local JSON, actions results, services, XML, oData and so on &ndash; check! Defining header and text key are the properties in your data to be displayed for each record, the initial bind depth set to 0 will let the list know we have provided just the data for the main list (otherwise the list will ignore those layouts since child data is not loaded). Sorting and filtering are truly easy to enable with just a property and you can also customize them with presets and in them setting <em>&quot;showGrouping&quot;:&quot;true </em>causes the list to group the sorted results just like the screeenshots above. And yes you can define custom sorting functions and group comparers if you so desire, but for our basic demo there&rsquo;s no need. In the child layout we again set the source to a actiong link and the <span style="text-decoration:underline;"><em>data-bindings=&#39;{&quot;customerId&quot;:&quot;CustomerID&quot;}&#39;</em> <span style="text-decoration:underline;">property instructs the list to include this as part of the links query so we can send the data for the right customer and the result:</span></span></p>
<p><img title="Infragistics jQuery Mobile List View auto generated details sub page(default b swatch)" alt="Infragistics jQuery Mobile List View auto generated details sub page(default b swatch)" src="http://media.infragistics.com/community/Release/12.1/jQuery/Mobile_Controls/igListView_ios_details.png" /></p>
<p>This sub-page is all auto-generated for you, navigated to using AJAX, back button and history maintained!</p>
<p>Adding the rating is just as easy, again either through markup, helpers or initializing with script. Also as we mentioned you have the ability to now develop against specialized touch events so you can provide that little extra interaction to mobile users &ndash; we would use the long tap gesture to reset the rating and also handle the changed event:</p>
<p>&nbsp;</p>
<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:b161fe58-6efc-4cae-b907-b662c7f13fe7" class="wlWriterEditableSmartContent">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:300px;overflow:auto;"><ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="background:#ffff00;">@</span><span style="color:#0000ff;">using</span> Infragistics.Web.Mvc</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//load the resources:</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;$.ig.loader({</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scriptPath: <span style="color:#800000;">&quot;../../Scripts/Infragistics-mobile/js/&quot;</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cssPath: <span style="color:#800000;">&quot;../../Content/Infragistics-mobile/css/&quot;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resources: <span style="color:#800000;">&quot;igmRating&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;});</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">// show the changed value</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;$(document).delegate(<span style="color:#800000;">&quot;#rating&quot;</span>, <span style="color:#800000;">&quot;igratingvaluechange&quot;</span>, <span style="color:#0000ff;">function</span> (evt, ui) {</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">var</span> voteCount = $(<span style="color:#800000;">&quot;.selector&quot;</span>).igRating(<span style="color:#800000;">&quot;option&quot;</span>, <span style="color:#800000;">&quot;voteCount&quot;</span>);</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#800000;">&quot;#ratingValue&quot;</span>).text(<span style="color:#800000;">&quot;Rated: &quot;</span> + ui.value + <span style="color:#800000;">&quot; star(s)!&quot;</span>);</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;});</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">// reset the rating on tap hol</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;$(document).bind(<span style="color:#800000;">&quot;#rating&quot;</span>, <span style="color:#800000;">&quot;taphold&quot;</span>, <span style="color:#0000ff;">function</span> (evt, ui) {</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">if</span> (!Modernizr.touch) {</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span>;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#800000;">&quot;#rating&quot;</span>).igRating(<span style="color:#800000;">&quot;value&quot;</span>, 0);</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;}); </li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">h2</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;">some rating<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">h2</span><span style="color:#0000ff;">&gt;</span></li>
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">P</span><span style="color:#0000ff;">&gt;</span> Tap to set value, tap and hold to reset (zero). <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">P</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;"><span style="color:#006400;">&lt;!-- Markup defined --&gt;</span></li>
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">div</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">=&quot;rating&quot;</span> <span style="color:#ff0000;">data-role</span><span style="color:#0000ff;">=&quot;igrating&quot;</span> <span style="color:#ff0000;">data-value</span><span style="color:#0000ff;">=&quot;3&quot;&gt;</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">div</span><span style="color:#0000ff;">&gt;</span></li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">p</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">=&quot;ratingValue&quot;&gt;&lt;/</span><span style="color:#800000;">p</span><span style="color:#0000ff;">&gt;</span></li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">p</span><span style="color:#0000ff;">&gt;</span> Read-only Rating defined with the MVC helper:<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">p</span><span style="color:#0000ff;">&gt;</span></li>
<li>&nbsp;&nbsp;<span style="background:#ffff00;">@(</span>Html.InfragisticsMobile().Rating()</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Value(4)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.ReadOnly(<span style="color:#0000ff;">true</span>)</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Render()</li>
<li><span style="background:#ffff00;">)</span></li>
</ol></div>
</div>
</div>
<p>&nbsp;</p>
<p>You can get and set rating&rsquo;s value and vote count at all times and the changed event offers both the new and old values along with regular references to owner and so on. Read-only mode rating converts to a smaller form (no longer need to be big enough to be touched):</p>
<p><img title="Infragistics jQuery Mobile Rating with iOS theme in default c swatch and read-only version." alt="Infragistics jQuery Mobile Rating with iOS theme in default c swatch and read-only version." src="http://media.infragistics.com/community/Release/12.1/jQuery/Mobile_Controls/igRating_readonly_ios_default_swatch.png" /></p>
<p>And, lastly, you can always override the default images or their locations to change the appearance of the control to match your theme. Below I&rsquo;ve change the non-iOS default stars for the rating form yellow to blue to match my theme&rsquo;s looks:</p>
<p><img title="Infragistics jQuery Mobile Rating with iOS theme in ThemeRoller built metro style theme and customized items." alt="Infragistics jQuery Mobile Rating with iOS theme in ThemeRoller built metro style theme and customized items." src="http://media.infragistics.com/community/Release/12.1/jQuery/Mobile_Controls/igRating_metro.png" /></p>
<h1>Wrapping Up</h1>
<p>If you want to build a mobile friendly app the jQuery Mobile framework is an excellent choice and we are offering that extra functionality for you to take advantage of &ndash; hierarchical list with templating, advanced filtering, sorting, grouping and impressive load on demand features and support for a wide array of data sources and a beautiful mobile rating optimized for touch interactions to truly score you those five stars! And there&rsquo;s a bonus &ndash; everything is optimized for mobile devices, but it looks and works perfectly good on a desktop as well!</p>
<p><em>I strongly recommend to take a closer look into jQuery Mobile and check out our<span style="text-decoration:underline;"> </span></em><a title="NetAdvantage for jQuery Online Samples" href="http://samples.infragistics.com/jquery" target="_blank"><em>awesome samples</em></a><em> (there are codes in there for you to scan and try them on you mobile device too!). Also you can download a fully functional unlimited trial of </em><a title="The best HTML5 applications call for brilliant Data Visualization and jaw-dropping performance!" href="http://www.infragistics.com/dotnet/netadvantage/jquery-controls.aspx#Overview" target="_blank"><em>NetAdvantage for jQuery</em></a><em> and the </em><a title="Infragistics jQuery Mobile List view and Rating ASP.NET MVC 4 Demo app." href="http://media.infragistics.com/community/Release/12.1/jQuery/Mobile_Controls/jQueryMobile_List_Rating.zip"><em>Demo Project for this Blog</em></a><em> &ndash; an APS.NET MVC 4 mobile application you&rsquo;ve seen bits from above and should definitely try!</em></p>
<p><em>Follow us on Twitter </em><a title="That would be me" href="https://twitter.com/DamyanPetev" target="_blank"><em>@DamyanPetev</em></a><em> and </em><a title="Infragistics on Twitter" href="https://twitter.com/infragistics" target="_blank"><em>@Infragistics</em></a><em> and join the competition on </em><a title="Infragistics on Facebook" href="http://www.facebook.com/infragistics" target="_blank"><em>Facebook</em></a><em>!</em></p>Combining different data sources in jQuery: Fun with the Infragistics Mashup Data Sourcehttp://community.infragistics.com/blogs/damyan_petev/archive/2012/03/08/combining-different-data-sources-in-jquery-fun-with-the-infragistics-mashup-data-source.aspxThu, 08 Mar 2012 15:10:00 GMT7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:337077dpetev<p>Reading our blogs often makes it almost guaranteed that you have seen us mention our jQuery data source here and there or even spot it in code snippets. And while it appears alongside other controls on regular basis, its presence is actually much more impactful than what you may expect from a non-visual component. It&rsquo;s one of those working their magic behind the scenes type &ndash; and that&rsquo;s not in odd places, but basically with every data-bound control. The <a target="_blank" href="http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=igDataSource_igDataSource_Overview.html" title="igDataScource Overview in the Online Help Topics">igDataScource</a> is in fact the force that feeds data to almost every control in the NetAdvantage for JQuery family. You&rsquo;d wonder then why the shy-of-attention attitude then? Well, it&rsquo;s simple &ndash; it&rsquo;s meant to shine while being barely noticeable and saving you all the effort that accessing and transforming data from various sources can take. The component allows for multiple types of data and origin &ndash; a range of web services and local data or even when all else fails - the option to feed your data through data-returning function. You will also find quite a few classes that extend it to provide some predefined setting for greater ease of use in the most common cases. Since we put the focus on that it&rsquo;s probably time to mention that with the latest release the numbers of supported scenarios by multiple implementations got bolstered a bit more, both of them really, with a CPT (Community Technology Preview) of a very interesting &lsquo;type&rsquo; of data source &ndash; the Mashup Data Source. </p>
<h1>Introduction</h1>
<p>Now this would be somewhat off-topic, but&nbsp; the spellchecker insists this is misspelled and I tend to disagree based on this <a target="_blank" href="http://en.wikipedia.org/wiki/Mashup_(web_application_hybrid)" title="Mashup article on Wikipedia">article about Mashup on Wikipedia</a>. And to get back on topic, on that page you can read that the term Mashup can refer to a web page/application &ldquo;that uses and combines data,[..]&rdquo; -&nbsp; I am cutting this quote off here. I believe that is more than enough to give you a decent hint what would a component, that serves as middle layer between data and data-bound controls, would do if it has &lsquo;mashup&rsquo; in its name. Pretty straightforward&nbsp; - the igMashupDataSource is an extension of the base igDataScource and it allows you to combine entries from different sources into one. And since I believe this fits so well I&rsquo;ll also add that the goal is &ldquo;to produce enriched results that were not necessarily the original reason for producing the raw source data.&rdquo; - and I find that thought very pleasing and that is exactly how it should be &ndash; this component is not just useful, but also a purveyor of satisfaction and fun &ndash; thus, the title above. And this should happen fast and easy and seamless - you still get all the familiar functionality inherited from base class or can also add to already available settings in case you have a running project. </p>
<p>Of course there&rsquo;s a very minor catch, if you can even call it that &ndash; it&rsquo;s not as simple as pointing to two sources and wait for them to be combined. For that to happen you will have to provide a common key. So while not meant to be combined, still not that random data after all? Well, depends on the case and how look at it &ndash; data can be coming from sources that know nothing of each other, yet share keys or you can tweak one to fit or one or all of the sources can be your own &ndash; either way you get a single collection consumable by a single control and you get plenty of freedom &ndash; I&rsquo;d put a &ldquo;fun&rdquo; label on that, too. Let&rsquo;s say you have data that is publicly available and therefore you&rsquo;d imagine it&rsquo;s two things &ndash; probably read-only and while it can be rich, it might still be missing something you need and there&rsquo;s nothing you can do about that. Or can you? That&rsquo;s exactly it &ndash; you can combine two compatible public sources or enrich what is available with data of your own <strong>and</strong> those can be with not only different origin, but also with different type.</p>
<p>Note: I&rsquo;d like to stress one more time this is still a CTP component and therefore it is very possible that it may not function fully and / or some things might be very different in the final version of it.</p>
<h1>Getting started</h1>
<p>As mentioned before the component is an extension of the base data source class and it should come as no surprise that using it feels very familiar and not that much different. The only additional things you will see is a data source property outside the inherited one and a property indicating whether records that have no data in all sources ( therefore they are partial) should be ignored. The latter is mean to let you get just the final results you want &ndash; whether it&rsquo;s all of records or just a &lsquo;section&rsquo; of only those that exist in all sources. The data source is what I&rsquo;d describe as the &lsquo;master&rsquo; one and it takes an array of data sources itself and this is where your data from different origins comes together. </p>
<p><strong><em>Preparations</em></strong></p>
<p>Before that there are as always some preparations &ndash; adding the required resources and some setup to use the assorted data. Starting off with some resources which this time can be as diverse as you scenario requires &ndash; since it is a non-visual component that is built as a JavaScript class it doesn&rsquo;t rely on jQuery UI scripts and therefore you can only reference the default jQuery&nbsp; library and the &lsquo;ig.util.js&rsquo; where the component is. And even though you can do that and use the Mashup Data Source for anything you see fit, it&rsquo;s only in rare occasions when you wouldn&rsquo;t want to present it nicely too. And again how to do that comes with enough freedom(including displaying it in a table using templating as seen in our <a target="_blank" href="http://samples.infragistics.com/jquery/data-source/mashup-data-source" title="NetAdvantage for jQuery online samples - Mashup data source">NetAdvantage for jQuery online samples</a> ), so for this example I will use our jQuery Hierarchical grid. For that reason below in snippets and in the demo project you will see both jQuery and jQuery UI libraries, along with the full Infragistics UI scripts file.</p>
<p>Let&rsquo;s define two sources for our main data layout &ndash; one being a small sample from the <a target="_blank" href="http://developer.netflix.com/docs/oData_Catalog">Netflix OData catalog</a> and the other one being our very own xml file &ndash; the basic idea behind this is to take such online data and add your personal notes to it. We would need to define origin and schema to apply on those:</p>
<div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c788c70f-2bec-4a9c-a1fb-34b780252d27" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:300px;overflow:auto;"><ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#006400;">&lt;!--CSS --&gt;</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">link</span> <span style="color:#ff0000;">href</span><span style="color:#0000ff;">=&quot;../../Content/themes/min/ig/jquery.ui.custom.min.css&quot;</span> <span style="color:#ff0000;">rel</span><span style="color:#0000ff;">=&quot;stylesheet&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;text/css&quot;</span> <span style="color:#0000ff;">/&gt;</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">link</span> <span style="color:#ff0000;">href</span><span style="color:#0000ff;">=&quot;../../Content/themes/base/ig.ui.min.css&quot;</span> <span style="color:#ff0000;">rel</span><span style="color:#0000ff;">=&quot;stylesheet&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;text/css&quot;</span> <span style="color:#0000ff;">/&gt;</span></li>
<li><span style="color:#006400;">&lt;!-- Scripts --&gt;</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">script</span> <span style="color:#ff0000;">src</span><span style="color:#0000ff;">=&quot;../../Scripts/jquery-1.5.1.min.js&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;text/javascript&quot;&gt;&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">script</span> <span style="color:#ff0000;">src</span><span style="color:#0000ff;">=&quot;../../Scripts/jquery-ui-1.8.11.min.js&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;text/javascript&quot;&gt;&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">script</span> <span style="color:#ff0000;">src</span><span style="color:#0000ff;">=&quot;../../Scripts/ig.ui.min.js&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;text/javascript&quot;&gt;&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">script</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;text/javascript&quot;&gt;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">var</span> url, oDataSchema, xmlDoc, xmlSchema,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mashupSources, dsMashup;</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;url = <span style="color:#800000;">&quot;http://odata.netflix.com/Catalog/Titles?$format=json&amp;$callback=?&amp;$top=10&quot;</span>;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;oDataSchema = <span style="color:#0000ff;">new</span> $.ig.DataSchema(<span style="color:#800000;">&quot;json&quot;</span>, { fields: [</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ name: <span style="color:#800000;">&quot;Id&quot;</span> },</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ name: <span style="color:#800000;">&quot;Name&quot;</span> },</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ name: <span style="color:#800000;">&quot;BoxArt&quot;</span> },</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ name: <span style="color:#800000;">&quot;AverageRating&quot;}</span>],</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;searchField: <span style="color:#800000;">&quot;d&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;});</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;xmlDoc = loadXMLDoc(<span style="color:#800000;">&quot;/Content/MovieNotes.xml&quot;</span>);</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;xmlSchema = <span style="color:#0000ff;">new</span> $.ig.DataSchema(<span style="color:#800000;">&quot;xml&quot;</span>, {</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fields: [</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ name: <span style="color:#800000;">&quot;Id&quot;</span>, xpath: <span style="color:#800000;">&quot;Id&quot;</span> },</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ name: <span style="color:#800000;">&quot;Notes&quot;</span>, xpath: <span style="color:#800000;">&quot;Notes&quot;</span> }</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;searchField: <span style="color:#800000;">&quot;//Movie&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;});</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">function</span> loadXMLDoc(dname) {</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">if</span> (window.XMLHttpRequest) {</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xhttp = <span style="color:#0000ff;">new</span> XMLHttpRequest();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">else</span> {</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xhttp = <span style="color:#0000ff;">new</span> ActiveXObject(<span style="color:#800000;">&quot;Microsoft.XMLHTTP&quot;</span>);</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xhttp.open(<span style="color:#800000;">&quot;GET&quot;</span>, dname, <span style="color:#0000ff;">false</span>);</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xhttp.send();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">return</span> xhttp.responseText;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//continues...</span></li>
</ol></div>
</div>
</div>
<p>Of course for the XML file you can use <a target="_blank" href="http://api.jquery.com/jQuery.get/" title="jQuery get()">jQuery&rsquo;s get()</a> (short for $.ajax) to perform the HTTP GET request, too. Or that xml can come from just about anywhere as long as it is presented in a form the igDataSource accepts. Defining the schemas provides the way to navigate the responses&rsquo; structure and which fields to be taken. As for the contents of the xml file it&rsquo;s basically movies with ID and Notes nodes and you will find it in the demo project.</p>
<p>Then for a good measure I have an ASP.NET MVC action that returns JSON from a randomly generated values (again IDs and each having a collection of generated Fans with random initial and rating). The idea is that we would not only add a third source, but also it will be the sole provider for data of the child layouts in the hierarchical grid:</p>
<div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ac5e5de0-c9d1-4b62-b783-d26f08bca66f" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:400px;overflow:auto;"><ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;white-space:nowrap;">
<li>[<span style="color:#2b91af;">ActionName</span>(<span style="color:#a31515;">&quot;getData&quot;</span>)]</li>
<li style="background:#f3f3f3;"><span style="color:#0000ff;">public</span> <span style="color:#2b91af;">JsonResult</span> JsonSource()</li>
<li>{ </li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">var</span> mmData = <span style="color:#2b91af;">MoreMovieData</span>.Generate();</li>
<li>&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">return</span> Json(mmData, <span style="color:#2b91af;">JsonRequestBehavior</span>.AllowGet);</li>
<li style="background:#f3f3f3;">}</li>
</ol></div>
</div>
</div>
<p>Note: If you do decide to go with this make sure to check out <a target="_blank" href="http://forums.asp.net/t/1483387.aspx" title="Topic on the ASP.NET forums">this topic on the ASP.NET forums</a> for why we have JsonRequestBehavior.AllowGet in there and this <a target="_blank" href="http://haacked.com/archive/2009/06/25/json-hijacking.aspx" title="JSON Hijacking blog by Phil Haack">blog by Phil Haack</a> on the subject.</p>
<p><strong><em>All for one</em></strong></p>
<p>Now that we have three sources ready it is time to create our Mashup Data Source. As said before one of the things it provides is the &lsquo;master&rsquo; dataSource which takes an array of igDataSource instances to be combined:</p>
<div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:858eaf91-2783-47a7-96e3-a45dbfd16bb0" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:400px;overflow:auto;"><ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#006400;">//--- Defining the Mashup Data Source</span></li>
<li style="background:#f3f3f3;">mashupSources = [</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ type: <span style="color:#800000;">&quot;remoteUrl&quot;</span>, dataSource: url, schema: oDataSchema, responseDataType: <span style="color:#800000;">&quot;jsonp&quot;</span>, primaryKey: <span style="color:#800000;">&quot;Id&quot;</span> },</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ dataSource: xmlDoc, type: <span style="color:#800000;">&quot;xml&quot;</span>, primaryKey: <span style="color:#800000;">&quot;Id&quot;</span>, schema: xmlSchema },</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ type: <span style="color:#800000;">&quot;remoteUrl&quot;</span>, dataSource: <span style="color:#800000;">&#39;/Home/getData&#39;</span>, primaryKey: <span style="color:#800000;">&quot;Id&quot;</span> }</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;];</li>
<li>dsMashup = <span style="color:#0000ff;">new</span> $.ig.MashupDataSource({ dataSource: mashupSources });</li>
<li style="background:#f3f3f3;"><span style="color:#006400;">//--- Definition Ends</span></li>
<li><span style="color:#006400;">//continues...</span></li>
</ol></div>
</div>
</div>
<p>The data source (any of them) assumes that if given a string to that identically named property instead an IQueryable or an array, then that would be an URL that points to the data. So you can safely skip the defining of type being &lsquo;remoteUrl&rsquo; for both above. The first one is the Netflix OData as described above with URL and schema, the second is fairly obvious the xml file and the third is the JSON returning action in my Home controller.</p>
<p>That&rsquo;s it! Now you are free to do with the data what you see fit &ndash; call its dataBind() method that does all sorts of stuff for you ( fire bind related events, analiza data, perform requests, transform data and so on) and you can use the callback function to display the data once it&rsquo;s ready like in the sample linked above OR you can provide it to an UI control to display as we will now do with the igHIerarchicalGrid.</p>
<p><strong><em>Presenting your data</em></strong></p>
<p>It&rsquo;s almost as easy as it gets &ndash; you setup the jQuery Hierarchical grid widget like you normally would and use the keys from any source freely, just like that:</p>
<div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:30dd84fc-8868-4ad4-87a0-f6480c9f18ba" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#fff;max-height:400px;overflow:auto;"><ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;">
<li><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">table</span> <span style="color:#ff0000;">id</span><span style="color:#0000ff;">=&quot;grid&quot;&gt;&lt;/</span><span style="color:#800000;">table</span><span style="color:#0000ff;">&gt;</span></li>
</ol></div>
</div>
</div>
<div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ba60f9b5-3dcb-4f9d-99c1-434b8190322f" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:200px;overflow:auto;"><ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;white-space:nowrap;">
<li>&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color:#800000;">&quot;#grid&quot;</span>).igHierarchicalGrid({</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;autoGenerateColumns: <span style="color:#0000ff;">false</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;autoGenerateLayouts: <span style="color:#0000ff;">false</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;primaryKey: <span style="color:#800000;">&quot;Id&quot;</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;defaultChildrenDataProperty: <span style="color:#800000;">&quot;Fans&quot;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;childrenDataProperty: <span style="color:#800000;">&quot;Fans&quot;</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;columns: [</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//{ headerText: &quot;ID&quot;, key: &quot;Id&quot; }, /* optional row if you want to see the ID */</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{headerText: <span style="color:#800000;">&quot;Movie Name&quot;</span>, key: <span style="color:#800000;">&quot;Name&quot;</span> },</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ headerText: <span style="color:#800000;">&quot;Image&quot;</span>, key: <span style="color:#800000;">&quot;BoxArt&quot;</span>, format: <span style="color:#800000;">&quot;&lt;img src=\&quot;{0}\&quot; class=&#39;tooltip-grid-image&#39;&gt;&lt;/img&gt;&quot;</span> },</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ headerText: <span style="color:#800000;">&quot;Average Rating&quot;</span>, key: <span style="color:#800000;">&quot;AverageRating&quot;</span> },</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ headerText: <span style="color:#800000;">&quot;Notes from XML&quot;</span>, key: <span style="color:#800000;">&quot;Notes&quot;</span> }</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;columnLayouts: [</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;autoGenerateColumns: <span style="color:#0000ff;">true</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;primaryKey: <span style="color:#800000;">&quot;Id&quot;</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataSource: dsMashup,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: <span style="color:#800000;">&quot;100%&quot;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: <span style="color:#800000;">&quot;500px&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;});</li>
<li style="background:#f3f3f3;">});</li>
<li><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000ff;">&gt;</span></li>
</ol></div>
</div>
</div>
<p>As seen in column definitions you shouldn&rsquo;t feel the difference from using a single source &ndash; and that&rsquo;s the whole point! And just like that set the dataSource of the grid to our Mashup (line 20) and you are done. </p>
<h1>Results</h1>
<p>And just like that you have a hierarchical grid, data gathered from three different origins &ndash; all done fast and easy, keeping to familiar API and methods with a result that is not only very functional and neat but also looking quite well :</p>
<p><img src="http://media.infragistics.com/community/Release/11.2/JQUERY/Mashup-Data-Source/Mashup-data-source_hierarchical-grid.png" alt="jQuery Mashup Data Source consumed by a hierarchical grid" title="jQuery Mashup Data Source consumed by a hierarchical grid" /></p>
<p>Again the first 3 columns come directly from the Netflix catalogue, the Notes next to them come from an xml file. The child layouts in this structure come from randomly generated collection on the server-side just for the sake of the example and .. for the fun, really.</p>
<h1>Conclusion</h1>
<p>From this blog you&rsquo;ve hopefully learned a bit more about the ever so important jQuery Data Source component that is there for every data-bound control to ease your work so much. You&rsquo;ve also seen what the Mashup version of it can do, how you can combine data sources into a single collection and how you can display them with style and maintain familiar feeling and existing functionality with little to no hassle. The again what you would do with it is really up to your needs and for almost any scenario this component is equipped to handle. </p>
<p>Some useful links: <a target="_blank" href="http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=igDataSource_igDataSource_Overview.html" title="Help Topics on the NetAdvantage for jQuery Online Documentation">Our Online Documentation</a>, the <a target="_blank" href="http://help.infragistics.com/jQuery/2011.2/ig.DataSource" title="NetAdvantage for jQuery Data SOurce API references">API references in there</a> and the <a target="_blank" href="http://samples.infragistics.com/jquery/data-source" title="NetAdvantage for jQuery Online Samples : Data Source">Online samples</a> and as always you can download the <a href="http://media.infragistics.com/community/Release/11.2/JQUERY/Mashup-Data-Source/MashuDataSource_Demo.zip">demo project (ASP.NET MVC)</a>.</p>jQuery Hierarchical Grid - Load On Demandhttp://community.infragistics.com/blogs/damyan_petev/archive/2012/02/15/jquery-hierarchical-grid-load-on-demand.aspxWed, 15 Feb 2012 13:00:00 GMT7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:332605dpetev<p>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&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 &ndash; collapsing and expanding layouts sounds like a great target &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 &ndash; the hierarchical grid is relying on the flat igGrid control to display child layouts and it creates an instance <strong><em>only</em></strong> 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. &ldquo;Good!&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 &lsquo;Load On Demand&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!</p>
<p>Also here&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 :)</p>
<p><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" /></p>
<h1>Load on Demand with jQuery </h1>
<p>Now if you&rsquo;ve been examining the jQuery API of the Hierarchical Grid you might be wondering where is that &lsquo;loadOnDemand&rsquo; property? Simply put, the jQuery widget doesn&rsquo;t really have one. To be completely thorough&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&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 <a title="Open Data Protocol (OData) homepage." href="http://www.odata.org/" target="_blank">OData (Open Data Protocol)</a> and with the very nature of the protocol that spells querying data (including paging, ordering and filtering) what follows seems completely natural &ndash; when presented with OData the grid will use it to request data only when needed &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:</p>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:300px;overflow:auto;"> <ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li>$(<span style="color:#800000;">&quot;#hierarchicalGrid&quot;</span>).igHierarchicalGrid({</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//--Set up for Load on demand follows:</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;odata: <span style="color:#0000ff;">true</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;initialDataBindDepth: 0,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;dataSource: oDataInJson,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;responseDataKey: <span style="color:#800000;">&#39;d&#39;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//--end--</span></li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;autoGenerateColumns: <span style="color:#0000ff;">true</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;primaryKey: <span style="color:#800000;">&quot;ID&quot;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;columnLayouts: [</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: <span style="color:#800000;">&quot;Products&quot;</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;responseDataKey: <span style="color:#800000;">&#39;d&#39;</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;childrenDataProperty: <span style="color:#800000;">&quot;Products&quot;</span>,</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;autoGenerateColumns: <span style="color:#0000ff;">true</span>,</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;primaryKey: <span style="color:#800000;">&quot;ID&quot;</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;],</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;width: <span style="color:#800000;">&quot;700px&quot;</span>,</li>
<li style="background:#f3f3f3;">});</li>
</ol> </div>
</div>
</div>
<p>As seen in lines 4 through 7 there isn&rsquo;t all too much complication about it &ndash; make the grid aware OData will be used (setting the respective property to &lsquo;true&rsquo;) and provide a source. </p>
<p>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 &ndash;1 for the &ldquo;I don&rsquo;t know! Can&rsquo;t you just figure it out and load everything?&rdquo; case, when the goal is loading on demand you want that to be zero &ndash; as in just the first(parent) tier of entries will be loaded.</p>
<p>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&rsquo;s have a more descriptive example &ndash; as seen above is is set to &lsquo;d&rsquo; and that is because in that demo the sample OData service response looks like.. </p>
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;width:97.5%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum1"> 1:</span> ?({</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum2"> 2:</span> <span style="color:#006080;">&quot;d&quot;</span> : [</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum3"> 3:</span> {</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum4"> 4:</span> <span style="color:#006080;">&quot;__metadata&quot;</span>: {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum5"> 5:</span> <span style="color:#006080;">&quot;uri&quot;</span>: <span style="color:#006080;">&quot;http://services.odata.org/OData/OData.svc/Categories(0)&quot;</span>, <span style="color:#006080;">&quot;type&quot;</span>: <span style="color:#006080;">&quot;ODataDemo.Category&quot;</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum6"> 6:</span> }, <span style="color:#006080;">&quot;ID&quot;</span>: 0, <span style="color:#006080;">&quot;Name&quot;</span>: <span style="color:#006080;">&quot;Food&quot;</span>, <span style="color:#006080;">&quot;Products&quot;</span>: {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum7"> 7:</span> <span style="color:#008000;">//rest is omitted</span></pre>
</div>
</div>
<p>Now take the NorthWind sample service for example:</p>
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;width:97.5%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum1"> 1:</span> ?({</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum2"> 2:</span> <span style="color:#006080;">&quot;d&quot;</span> : {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum3"> 3:</span> <span style="color:#006080;">&quot;results&quot;</span>: [</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum4"> 4:</span> {</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum5"> 5:</span> <span style="color:#006080;">&quot;__metadata&quot;</span>: {</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum6"> 6:</span> <span style="color:#006080;">&quot;uri&quot;</span>: <span style="color:#006080;">&quot;http://services.odata.org/Northwind/Northwind.svc/Customers(&#39;ALFKI&#39;)&quot;</span>, <span style="color:#006080;">&quot;type&quot;</span>: <span style="color:#006080;">&quot;NorthwindModel.Customer&quot;</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum7"> 7:</span> }, <span style="color:#006080;">&quot;CustomerID&quot;</span>: <span style="color:#006080;">&quot;ALFKI&quot;</span>, <span style="color:#006080;">&quot;CompanyName&quot;</span>: <span style="color:#006080;">&quot;Alfreds Futterkiste&quot;</span>, <span style="color:#006080;">&quot;ContactName&quot;</span>: <span style="color:#006080;">&quot;Maria Anders&quot;</span>, <span style="color:#006080;">&quot;ContactTitle&quot;</span>: <span style="color:#006080;">&quot;Sales Representative&quot;</span>, <span style="color:#006080;">&quot;Address&quot;</span>: <span style="color:#006080;">&quot;Obere Str. 57&quot;</span>, <span style="color:#006080;">&quot;City&quot;</span>: <span style="color:#006080;">&quot;Berlin&quot;</span>, <span style="color:#006080;">&quot;Region&quot;</span>: <span style="color:#0000ff;">null</span>, <span style="color:#006080;">&quot;PostalCode&quot;</span>: <span style="color:#006080;">&quot;12209&quot;</span>, <span style="color:#006080;">&quot;Country&quot;</span>: <span style="color:#006080;">&quot;Germany&quot;</span>, <span style="color:#006080;">&quot;Phone&quot;</span>: <span style="color:#006080;">&quot;030-0074321&quot;</span>, <span style="color:#006080;">&quot;Fax&quot;</span>: <span style="color:#006080;">&quot;030-0076545&quot;</span>, <span style="color:#006080;">&quot;Orders&quot;</span>: {</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:&#39;Courier New&#39;, courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"><span style="color:#606060;" id="lnum8"> 8:</span> <span style="color:#008000;">//rest is omitted</span></pre>
</div>
</div>
<p>In this case the response key would be &ldquo;d.results&rdquo;. Simple enough and again specific to how you present your data.</p>
<p>In the light of all this you can check out Taz&rsquo;s blog on <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">Using OData with jQuery Hierarchical Grid</a> where you can find not only a full guide but also a link to a live demo!</p>
<p>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:</p>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:400px;overflow:auto;">
<ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">var</span> oDataInJson = <span style="color:#0000ff;">new</span> $.ig.JSONPDataSource(</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;{ dataSource: <span style="color:#800000;">&#39;http://services.odata.org/OData/OData.svc/Categories?$format=json&amp;$callback=?&#39;</span>, </li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;responseDataKey: <span style="color:#800000;">&quot;d&quot;</span> </li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;});</li>
</ol>
</div>
</div>
</div>
<p>You can read more about this control in our&nbsp; <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">Help Topics</a>.</p>
<h1>Load On Demand with ASP.NET MVC</h1>
<p>Unlike the majority of our jQuery products where the helpers mostly mirror the widget&rsquo;s settings and add some comforts for those used to writing in a managed environment, this time it&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&nbsp; responses to the client in JSON format. To be more specific it is the grid&rsquo;s model that provides the support for that. There&rsquo;s a catch though &ndash; the responses use the model&rsquo;s GetData() method and&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 &ndash; the model creating is best done in a separate method and here&rsquo;s the full code for one:</p>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#fff;max-height:400px;overflow:auto;">
<ol style="background:#ffffff;margin:0;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">using</span> Infragistics.Web.Mvc;</li>
</ol>
</div>
</div>
</div>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:300px;overflow:auto;">
<ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">private</span> <span style="color:#2b91af;">GridModel</span> CreateGridModel()</li>
<li style="background:#f3f3f3;">{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GridModel</span> grid = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridModel</span>();</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">// Set up properties and columns:</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.AutoGenerateColumns = <span style="color:#0000ff;">false</span>;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;grid.Columns = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">GridColumn</span>&gt;();</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.Columns.Add(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumn</span>(<span style="color:#a31515;">&quot;Customer&quot;</span>, <span style="color:#a31515;">&quot;CustomerID&quot;</span>, <span style="color:#a31515;">&quot;string&quot;</span>, <span style="color:#a31515;">&quot;300px&quot;</span>));</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;grid.Columns.Add(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumn</span>(<span style="color:#a31515;">&quot;Company Name&quot;</span>, <span style="color:#a31515;">&quot;CompanyName&quot;</span>, <span style="color:#a31515;">&quot;string&quot;</span>, <span style="color:#a31515;">&quot;150px&quot;</span>));</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.Columns.Add(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumn</span>(<span style="color:#a31515;">&quot;Country&quot;</span>, <span style="color:#a31515;">&quot;Country&quot;</span>, <span style="color:#a31515;">&quot;string&quot;</span>, <span style="color:#a31515;">&quot;150px&quot;</span>));</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.PrimaryKey = <span style="color:#a31515;">&quot;CustomerID&quot;</span>;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;grid.AutoGenerateLayouts = <span style="color:#0000ff;">false</span>;</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">// Create child layout</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GridColumnLayoutModel</span> layout = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumnLayoutModel</span>();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;layout.Key = <span style="color:#a31515;">&quot;Orders&quot;</span>;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;layout.ForeignKey = <span style="color:#a31515;">&quot;CustomerID&quot;</span>;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;layout.PrimaryKey = <span style="color:#a31515;">&quot;OrderID&quot;</span>;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;layout.AutoGenerateColumns = <span style="color:#0000ff;">false</span>;</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;layout.Columns = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">GridColumn</span>&gt;();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;layout.Columns.Add(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumn</span>(<span style="color:#a31515;">&quot;Order ID&quot;</span>, <span style="color:#a31515;">&quot;OrderID&quot;</span>, <span style="color:#a31515;">&quot;number&quot;</span>, <span style="color:#a31515;">&quot;100px&quot;</span>));</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;layout.Columns.Add(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumn</span>(<span style="color:#a31515;">&quot;Customer&quot;</span>, <span style="color:#a31515;">&quot;CustomerID&quot;</span>, <span style="color:#a31515;">&quot;string&quot;</span>, <span style="color:#a31515;">&quot;100px&quot;</span>));</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;layout.Columns.Add(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumn</span>(<span style="color:#a31515;">&quot;Order Date&quot;</span>, <span style="color:#a31515;">&quot;OrderDate&quot;</span>, <span style="color:#a31515;">&quot;date&quot;</span>, <span style="color:#a31515;">&quot;150px&quot;</span>));</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;layout.Columns.Add(<span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridColumn</span>(<span style="color:#a31515;">&quot;Shipped Date&quot;</span>, <span style="color:#a31515;">&quot;ShippedDate&quot;</span>, <span style="color:#a31515;">&quot;date&quot;</span>, <span style="color:#a31515;">&quot;150px&quot;</span>));</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">// Add paging to child layouts (different from the parent&#39;s)</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GridPaging</span> layoutPaging = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridPaging</span>();</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;layoutPaging.VisiblePageCount = 2;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;layoutPaging.PageSize = 5;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;layoutPaging.Type = <span style="color:#2b91af;">OpType</span>.Remote;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;layout.Features.Add(layoutPaging);</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//add that layout to the grid</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.ColumnLayouts.Add(layout);</li>
<li>&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//most importantly turn Load On demand on and define response Urls:</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;grid.LoadOnDemand = <span style="color:#0000ff;">true</span>;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.DataSourceUrl = <span style="color:#0000ff;">this</span>.Url.Action(<span style="color:#a31515;">&quot;BindParent&quot;</span>);</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;grid.ColumnLayouts[0].DataSourceUrl = <span style="color:#0000ff;">this</span>.Url.Action(<span style="color:#a31515;">&quot;BindChild&quot;</span>);</li>
<li style="background:#f3f3f3;">&nbsp;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//Also add paging to the parent layout</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GridPaging</span> paging = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridPaging</span>();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;paging.VisiblePageCount = 2;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;paging.PageSize = 10;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;paging.Type = <span style="color:#2b91af;">OpType</span>.Remote;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.Features.Add(paging);</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">// Return the finished model</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">return</span> grid;</li>
<li style="background:#f3f3f3;">}</li>
</ol>
</div>
</div>
</div>
<p>You will have to scroll down a bit to get to the part we are interested in &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. </p>
<p>Now back to the subject of JSON responses as seen above we have defined a grid model with two levels of hierarchy &ndash; a parent entries with child entries. Therefore we have the &ldquo;BindParent&rdquo; and &ldquo;BindChild&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&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&rsquo;t have to worry about converting data yourself. This is how those look:</p>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:400px;overflow:auto;">
<ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">public</span> <span style="color:#2b91af;">JsonResult</span> BindParent()</li>
<li style="background:#f3f3f3;">{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//create a model</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GridModel</span> grid = CreateGridModel();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//set its datasource</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">var</span> dataContext = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">NorthwindDataContext</span>();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">var</span> dataSource = dataContext.Customers;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.DataSource = dataSource.Take(30);</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//and use the GetData() method to return the results</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">return</span> grid.GetData();</li>
<li>}</li>
</ol>
</div>
</div>
</div>
<p>And then you have the one for the child layout:</p>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:400px;overflow:auto;">
<ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li><span style="color:#0000ff;">public</span> <span style="color:#2b91af;">JsonResult</span> BindChild(<span style="color:#0000ff;">string</span> path, <span style="color:#0000ff;">string</span> layout)</li>
<li style="background:#f3f3f3;">{</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//create a model</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GridModel</span> grid = CreateGridModel();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//set its datasource</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">var</span> dataContext = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">NorthwindDataContext</span>();</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">var</span> dataSource = dataContext.Orders;</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;grid.DataSource = dataSource;</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#008000;">//and use the GetData() method to return the results</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">return</span> grid.GetData(path, layout);</li>
<li>}</li>
</ol>
</div>
</div>
</div>
<p>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 &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:</p>
<p>PrimaryKeyID/ChildPrimaryKeyID/AnotherChildKey[layout name]. </p>
<p>Based on how your grid/data is set up any of the expanded rows&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 &ndash; it is true to its name &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 &ndash; the PrimaryKeyID which would be the id of the expanded parent row and look like:</p>
<p><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." /></p>
<p>And as you may have already guessed an request with empty path would mean the parent level, thus the BindParent takes zero arguments. </p>
<h1>Events</h1>
<p>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 &ndash; <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">Handling Events in the igHierarchicalGrid</a>. 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 &ndash; first &lsquo;childrenPopulating&rsquo; and then the standard &lsquo;childrenPopulat<strong>ed</strong>&rsquo;. As always the &lsquo;-ing&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:</p>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:400px;overflow:auto;">
<ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;">
<li>$(<span style="color:#800000;">&quot;#hierarchicalGrid&quot;</span>).live(<span style="color:#800000;">&quot;ighierarchicalgridchildrenpopulating&quot;</span>, <span style="color:#0000ff;">function</span> (evt, args) {</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//you can decline loading data for certain rows, like some that may not even have child items</span></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//calcel out if calling row with key ID of 0</span></li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0000ff;">if</span> (args.id == <span style="color:#800000;">&quot;ID:0&quot;</span>)</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span>;}</li>
<li style="background:#f3f3f3;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">//define you own logic to hanle the event</span></li>
<li>});</li>
</ol>
</div>
</div>
</div>
<p>As you can find in our <a title="Hierarchical jQuery Grid control API" href="http://help.infragistics.com/jQuery/2011.2/ui.ighierarchicalgrid" target="_blank">API</a> and in Jordan&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&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.</p>
<h1>The Added benefits</h1>
<p>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 &ndash; the protocol providers support those features and the grid will make the appropriate requests when remote paging, filtering, sorting and even summaries!</p>
<p>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&rsquo;s request &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&rsquo;t even bother setting up URL key(s) for filtering or sorting like you are normally required to. Here&rsquo;s what you can <strong><em>simply add</em></strong> to the CreateModel method from above:</p>
<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">
<div style="border:#000080 1px solid;color:#000;font-family:&#39;Courier New&#39;, Courier, Monospace;font-size:10pt;">
<div style="background:#ddd;max-height:400px;overflow:auto;">
<ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;">
<li><span style="color:#008000;">//Add features:</span></li>
<li style="background:#f3f3f3;">&nbsp;<span style="color:#2b91af;">GridSorting</span> sorting = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridSorting</span>();</li>
<li>&nbsp;sorting.Type = <span style="color:#2b91af;">OpType</span>.Remote;</li>
<li style="background:#f3f3f3;">&nbsp;grid.Features.Add(sorting);</li>
<li>&nbsp;<span style="color:#2b91af;">GridPaging</span> paging = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridPaging</span>();</li>
<li style="background:#f3f3f3;">&nbsp;paging.PageSize = 10;</li>
<li>&nbsp;paging.Type = <span style="color:#2b91af;">OpType</span>.Remote;</li>
<li style="background:#f3f3f3;">&nbsp;grid.Features.Add(paging);</li>
<li>&nbsp;<span style="color:#2b91af;">GridFiltering</span> filtering = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">GridFiltering</span>();</li>
<li style="background:#f3f3f3;">&nbsp;filtering.Type = <span style="color:#2b91af;">OpType</span>.Remote;</li>
<li>&nbsp;filtering.Mode = <span style="color:#2b91af;">FilterMode</span>.Simple;</li>
<li style="background:#f3f3f3;">&nbsp;grid.Features.Add(filtering);</li>
</ol>
</div>
</div>
</div>
<h1>Conclusion</h1>
<p>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.</p>
<p>A read you might find interesting in our help topics would be the <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">Getting started with igGrid, oData and WCF Data Services</a> guide in our Help Topics which is another way you can consume OData with your grid.</p>
<p>Also head over to our <a title="jQuery Hierarchical Grid Sample" href="http://samples.infragistics.com/jquery/hierarchical-grid/hierarchical-grid-load-on-demand" target="_blank">Samples</a> to try it out and you can also download the <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">Demo project</a> accompanying this blog in which you will find implemented ASP.NET MVC using the wrapper and a pure jQuery / JavaScript implementation consuming OData.</p>Getting Started with igGrid, OData, and WCF Data Serviceshttp://community.infragistics.com/blogs/engineering/archive/2011/07/28/getting-started-with-iggrid-odata-and-wcf-data-services.aspxThu, 28 Jul 2011 18:54:00 GMT7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:296123amarisi<p>The igGrid is a client-side data grid with paging, filtering, and sorting functionality. It can bind to local data including XML, JSON, JavaScript arrays, HTML tables and remote data returned through web services.</p>
<p>The most seamless way to bind the igGrid to remote data is to use it in conjunction with OData. OData, or Open Data Protocol, operates over HTTP and provides a means of querying and updating data in JSON and AtomPub formats through a set of common URL conventions. This means that you can provide the grid with a URL to the OData service, set one property, and all of the paging, filtering, and sorting can be done remotely on the server without any additional configuration.</p>
<p>This article shows how to setup a client-side jQuery grid with remote paging, filtering, and sorting by setting up a WCF Data Service in an ASP.NET Web Application and setting two options on the igGrid.</p>
<p>1. Open Visual Studio and create a new ASP.NET Empty Web Application called &lsquo;igDataSourceWCFService&rsquo;:</p>
<p><b></b></p>
<p><b>Note</b>: this is a plain old ASP.NET Web Application &ndash; this is not ASP.NET MVC. NetAdvantage for jQuery is &lsquo;server agnostic&rsquo;, meaning it does not rely on any specific server-side architecture. While the product ships with built-in support for ASP.NET MVC, this server framework is not required to use the rich client-side functionality.</p>
<p><img height="231" width="602" src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_webapp.jpg" alt="" /></p>
<p>2. Add an App_Data folder to your project and add the AdventureWorks database into that folder:</p>
<p><strong>Note:</strong> To obtain the AdventureWorks database, download it <a href="http://msftdbprodsamples.codeplex.com/releases/view/37109">here</a>.</p>
<p><img src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_proj1.jpg" alt="" /></p>
<p>3. Next, add an ADO.NET Entity Data Model named AdventureWorksEntities.edmx to the project and point it to the AdventureWorks database:</p>
<p><img src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_addedm.jpg" alt="" /></p>
<p><img height="285" width="556" src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_edmdb.jpg" alt="" /></p>
<p>4. Choose the Product table to be included in the Entity Data Model:</p>
<p><img height="497" width="561" src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_edmtbl.jpg" alt="" /></p>
<p>5. Next add a WCF Data Service to the project named &lsquo;AdventureWorksService.svc&rsquo;:</p>
<p><img height="337" width="601" src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_addwcfds.jpg" alt="" /></p>
<p>6. At this point your project should look like this:</p>
<p><img src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_proj2.jpg" alt="" /></p>
<p>7. Next, open the &lsquo;AdventureWorksDataService&rsquo;. This class derives from DataService&lt;T&gt; where T has not yet been defined. Specify the type of your Entity Data Model here:</p>
<pre name="code" class="c#:nogutter">public class AdventureWorksDataService : DataService&lt;AdventureWorksLT2008_DataEntities&gt;</pre>
<p>8. Next, enable access to the Products table through the Data Service by adding this line of code within the InitializeService method:</p>
<pre name="code" class="c#:nogutter">public static void InitializeService(DataServiceConfiguration config
{
config.SetEntitySetAccessRule(&quot;Products&quot;, EntitySetRights.AllRead);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}</pre>
<p>9. WCF Data Services has native support for the Atom format. To enable JSON formatted data, you should download the <a href="http://archive.msdn.microsoft.com/DataServicesJSONP">JSONPSupportBehavior</a> code file and include it in your application.</p>
<p>10. Once the JSONPSupportBehavior.cs file is included in your application, make sure to change the namespace to match the namespace used in your application. Also, add the JSONPSupportBehavior attribute to your AdventureWorksDataService class:</p>
<pre name="code" class="c#:nogutter">[JSONPSupportBehavior]
public class AdventureWorksDataService : DataService&lt;AdventureWorksLT2008_DataEntities&gt;</pre>
<p>11. At this point, you can run the Web Application and access the data of the service so now it&rsquo;s time to setup the igGrid.</p>
<p>12. You will need the NetAdvantage for jQuery combined and minified script file, ig.ui.min.js, which comes with the product. In addition, you will need the jQuery, jQuery UI, and jQuery templates scripts to run the sample. This <a href="http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=Deployment_Guide_JavaScript_Resouces.html">help</a> article discusses referencing the required scripts and where the combined and minified scripts can be found.</p>
<p><b>Note</b>: You can download the full or trial product <a href="http://www.infragistics.com/dotnet/netadvantage/jquery-controls.aspx#Downloads">here</a>. The jQuery templates script can be obtained <a href="http://api.jquery.com/category/plugins/templates/">here</a>.</p>
<p>13. You should setup a scripts directory in your project and copy the JavaScript files into this folder. </p>
<p>14. Setup a styles directory and add the Infragistics themes directory to this folder. For more information on working with the jQuery themes for the igGrid, see <a href="http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=igGrid_Styling_and_Theming.html">this help topic</a>.</p>
<p>15. Next you can setup the sample page. You are going to add a new html page to the application and call it &lsquo;default.htm&rsquo;. Once that is done your project will look like this:</p>
<p><img src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_proj3.jpg" alt="" /></p>
<p>16. Open the default.htm file and include CSS links and script tags for the jQuery resources:</p>
<pre name="code" class="html:nogutter">&lt;head&gt;
&lt;link href=&quot;styles/themes/min/ig/jquery.ui.custom.min.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;link href=&quot;styles/themes/base/ig.ui.min.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;script src=&quot;scripts/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/jquery-ui.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/jquery.tmpl.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/ig.ui.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/head&gt;</pre>
<p>17. Next, add a TABLE element to the body of the HTML which will serve as the base element for the grid:</p>
<pre name="code" class="html:nogutter">&lt;body&gt;
&lt;table id=&#39;tableProducts&#39;&gt;&lt;/table&gt;
&lt;/body&gt;</pre>
<p>18. Add another script tag to the HEAD and instantiate an igGrid and define columns:</p>
<pre name="code" class="js:nogutter">&lt;script type=&quot;text/javascript&quot;&gt;
$(window).load(function () {
$(&#39;#tableProducts&#39;).igGrid({
height: &#39;500px&#39;,
width: &#39;800px&#39;,
autoGenerateColumns: false,
columns: [
{ headerText: &#39;ID&#39;, key: &#39;ProductID&#39;, dataType: &#39;number&#39; },
{ headerText: &#39;Name&#39;, key: &#39;Name&#39;, dataType: &#39;string&#39; },
{ headerText: &#39;Number&#39;, key: &#39;ProductNumber&#39;, dataType: &#39;string&#39; },
{ headerText: &#39;Cost&#39;, key: &#39;StandardCost&#39;, dataType: &#39;number&#39;, format: &#39;currency&#39;}
]
});
});
&lt;/script&gt;</pre>
<p>19. To bind the igGrid to data, two options should be set to define the URL for the data and the responseDataKey:</p>
<p>Note: The value <a href="http://www.odata.org/developers/protocols/json-format#RepresentingCollectionsOfEntries">d.results</a> is a standard response key for JSON data coming from a &lsquo;V2&rsquo; OData service</p>
<pre name="code" class="js:nogutter">responseDataKey: &#39;d.results&#39;,
dataSource: &#39;AdventureWorksDataService.svc/Products?$format=json&#39;,</pre>
<p>20. Finally, enable the features of the grid including the option to make them operate remotely:</p>
<pre name="code" class="js:nogutter">features: [
{
name: &#39;Selection&#39;,
mode: &#39;row&#39;,
multipleSelection: true
},
{
name: &#39;Paging&#39;,
type: &#39;remote&#39;,
pageSize: 15
},
{
name: &#39;Sorting&#39;,
type: &#39;remote&#39;
},
{
name: &#39;Filtering&#39;,
type: &#39;remote&#39;,
mode: &#39;advanced&#39;
}
]</pre>
<p>Run the sample and you will see the igGrid rendered. Combined with OData, the grid can filter, sort, and page data remotely by supplying a single URL as the datasource.</p>
<p><img height="384" width="614" src="http://dl.infragistics.com/community/images/aaronm/blog/2011-07-28/gdod_sample.jpg" alt="" /></p>
<p>&nbsp;</p>
<p><a href="http://dl.infragistics.com/community/jquery/codesamples/aaronm/2011-07-28/igGridOData.zip">Download Sample</a></p>
<p><strong>Note</strong>: The AdventureWorks database and NetAdvantage for jQuery resources are not included in the sample. Visit these links to obtain the software:</p>
<p><a href="http://msftdbprodsamples.codeplex.com/releases/view/37109">AdventureWorks Database</a></p>
<p><a href="http://www.infragistics.com/dotnet/netadvantage/jquery-controls.aspx#Downloads">NetAdvantage for jQuery</a></p>