<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JQWidgets &#8211; Sibeesh Passion</title>
	<atom:link href="https://mail.sibeeshpassion.com/category/products/jqwidgets/feed/" rel="self" type="application/rss+xml" />
	<link>https://mail.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 11 Jul 2018 16:20:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>JQWidgets &#8211; Sibeesh Passion</title>
	<link>https://mail.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Implement radio button selection in JQWidgets JQXGrid using checkbox</title>
		<link>https://mail.sibeeshpassion.com/implement-radio-button-selection-in-jqwidgets-jqxgrid-using-checkbox/</link>
					<comments>https://mail.sibeeshpassion.com/implement-radio-button-selection-in-jqwidgets-jqxgrid-using-checkbox/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 29 Jun 2016 05:22:53 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Radio button selection in JQWidgets JQXGrid]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=11720</guid>

					<description><![CDATA[In this post we will see how we can implement radio button selection feature to jQWidgets jQXGrid. As of now in JQXGrid, we don&#8217;t have this functionality yet, but still we can do it our self by using check box selection which is already available. We will load the grid with sample data and implement the radio button selection. If you are new to JQX Grid, you can see some tips here. I hope you will like this. Download Source Code You can always download the source code from here: Radio button selection in JQXGrid Background I am using JQXGrid [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can implement radio button selection feature to <a href="http://sibeeshpassion.com/category/products/jqwidgets/" target="_blank">jQWidgets </a><a href="http://sibeeshpassion.com/category/products/jqwidgets/jqx-grid/" target="_blank">jQXGrid</a>. As of now in JQXGrid, we don&#8217;t have this functionality yet, but still we can do it our self by using check box selection which is already available. We will load the grid with sample data and implement the radio button selection. If you are new to JQX Grid, you can see some tips <em><a href="http://sibeeshpassion.com/tag/jqx-grid/" target="_blank">here</a></em>. I hope you will like this. </p>
<p><strong>Download Source Code</strong></p>
<p>You can always download the source code from here: <a href="https://code.msdn.microsoft.com/Implement-radio-button-354fd876" target="_blank">Radio button selection in JQXGrid</a></p>
<p><strong>Background</strong></p>
<p>I am using JQXGrid in one of my project, where I wanted to implement the radio button selection, when I talked with JQXGrid development team, I was said that the functionality is not yet available. But they have given an option as <em>selectionmode: &#8216;checkbox&#8217;</em> with the help of that property we can implement the requirement. As you know, to load a jQWidget JQX Grid, there you need the following things as mandatory. </p>
<li>datafields</li>
<li>columns</li>
<li>localdata or server side data</li>
<p><strong>Using the code</strong></p>
<p>First of all, load the needed references. You can download the needed files from <a href="http://www.jqwidgets.com/download/" target="_blank">here</a>.</p>
<p>[html]<br />
   &lt;link rel=&quot;stylesheet&quot; href=&quot;jqwidgets/styles/jqx.base.css&quot; type=&quot;text/css&quot; /&gt;<br />
    &lt;script src=&quot;jquery-2.2.3.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.edit.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxcheckbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
[/html]</p>
<p>Now, we are going to set our data source, this time we will use a XML file as data source.</p>
<p>[xml]<br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot; standalone=&quot;yes&quot;?&gt;<br />
&lt;feed xml:base=&quot;http://services.odata.org/Northwind/Northwind.svc/&quot; xmlns:d=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices&quot; xmlns:m=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&quot; xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;<br />
  &lt;title type=&quot;text&quot;&gt;Orders&lt;/title&gt;<br />
  &lt;id&gt;http://services.odata.org/Northwind/Northwind.svc/Orders&lt;/id&gt;<br />
  &lt;updated&gt;2011-12-01T11:55:06Z&lt;/updated&gt;<br />
  &lt;link rel=&quot;self&quot; title=&quot;Orders&quot; href=&quot;Orders&quot; /&gt;<br />
  &lt;entry&gt;<br />
    &lt;id&gt;http://services.odata.org/Northwind/Northwind.svc/Orders(10248)&lt;/id&gt;<br />
    &lt;title type=&quot;text&quot;&gt;&lt;/title&gt;<br />
    &lt;updated&gt;2011-12-01T11:55:06Z&lt;/updated&gt;<br />
    &lt;author&gt;<br />
      &lt;name /&gt;<br />
    &lt;/author&gt;<br />
    &lt;link rel=&quot;edit&quot; title=&quot;Order&quot; href=&quot;Orders(10248)&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer&quot; type=&quot;application/atom+xml;type=entry&quot; title=&quot;Customer&quot; href=&quot;Orders(10248)/Customer&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Employee&quot; type=&quot;application/atom+xml;type=entry&quot; title=&quot;Employee&quot; href=&quot;Orders(10248)/Employee&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Order_Details&quot; type=&quot;application/atom+xml;type=feed&quot; title=&quot;Order_Details&quot; href=&quot;Orders(10248)/Order_Details&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Shipper&quot; type=&quot;application/atom+xml;type=entry&quot; title=&quot;Shipper&quot; href=&quot;Orders(10248)/Shipper&quot; /&gt;<br />
    &lt;category term=&quot;NorthwindModel.Order&quot; scheme=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&quot; /&gt;<br />
    &lt;content type=&quot;application/xml&quot;&gt;<br />
      &lt;m:properties&gt;<br />
        &lt;d:OrderID m:type=&quot;Edm.Int32&quot;&gt;10248&lt;/d:OrderID&gt;<br />
        &lt;d:CustomerID&gt;VINET&lt;/d:CustomerID&gt;<br />
        &lt;d:EmployeeID m:type=&quot;Edm.Int32&quot;&gt;5&lt;/d:EmployeeID&gt;<br />
        &lt;d:OrderDate m:type=&quot;Edm.DateTime&quot;&gt;1996-07-04T00:00:00&lt;/d:OrderDate&gt;<br />
        &lt;d:RequiredDate m:type=&quot;Edm.DateTime&quot;&gt;1996-08-01T00:00:00&lt;/d:RequiredDate&gt;<br />
        &lt;d:ShippedDate m:type=&quot;Edm.DateTime&quot;&gt;1996-07-16T00:00:00&lt;/d:ShippedDate&gt;<br />
        &lt;d:ShipVia m:type=&quot;Edm.Int32&quot;&gt;3&lt;/d:ShipVia&gt;<br />
        &lt;d:Freight m:type=&quot;Edm.Decimal&quot;&gt;32.3800&lt;/d:Freight&gt;<br />
        &lt;d:ShipName&gt;Vins et alcools Chevalier&lt;/d:ShipName&gt;<br />
        &lt;d:ShipAddress&gt;59 rue de l&#8217;Abbaye&lt;/d:ShipAddress&gt;<br />
        &lt;d:ShipCity&gt;Reims&lt;/d:ShipCity&gt;<br />
        &lt;d:ShipRegion m:null=&quot;true&quot; /&gt;<br />
        &lt;d:ShipPostalCode&gt;51100&lt;/d:ShipPostalCode&gt;<br />
        &lt;d:ShipCountry&gt;France&lt;/d:ShipCountry&gt;<br />
      &lt;/m:properties&gt;<br />
    &lt;/content&gt;<br />
  &lt;/entry&gt;<br />
  &lt;entry&gt;<br />
    &lt;id&gt;http://services.odata.org/Northwind/Northwind.svc/Orders(10249)&lt;/id&gt;<br />
    &lt;title type=&quot;text&quot;&gt;&lt;/title&gt;<br />
    &lt;updated&gt;2011-12-01T11:55:06Z&lt;/updated&gt;<br />
    &lt;author&gt;<br />
      &lt;name /&gt;<br />
    &lt;/author&gt;<br />
    &lt;link rel=&quot;edit&quot; title=&quot;Order&quot; href=&quot;Orders(10249)&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer&quot; type=&quot;application/atom+xml;type=entry&quot; title=&quot;Customer&quot; href=&quot;Orders(10249)/Customer&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Employee&quot; type=&quot;application/atom+xml;type=entry&quot; title=&quot;Employee&quot; href=&quot;Orders(10249)/Employee&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Order_Details&quot; type=&quot;application/atom+xml;type=feed&quot; title=&quot;Order_Details&quot; href=&quot;Orders(10249)/Order_Details&quot; /&gt;<br />
    &lt;link rel=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/related/Shipper&quot; type=&quot;application/atom+xml;type=entry&quot; title=&quot;Shipper&quot; href=&quot;Orders(10249)/Shipper&quot; /&gt;<br />
    &lt;category term=&quot;NorthwindModel.Order&quot; scheme=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&quot; /&gt;<br />
    &lt;content type=&quot;application/xml&quot;&gt;<br />
      &lt;m:properties&gt;<br />
        &lt;d:OrderID m:type=&quot;Edm.Int32&quot;&gt;10249&lt;/d:OrderID&gt;<br />
        &lt;d:CustomerID&gt;TOMSP&lt;/d:CustomerID&gt;<br />
        &lt;d:EmployeeID m:type=&quot;Edm.Int32&quot;&gt;6&lt;/d:EmployeeID&gt;<br />
        &lt;d:OrderDate m:type=&quot;Edm.DateTime&quot;&gt;1996-07-05T00:00:00&lt;/d:OrderDate&gt;<br />
        &lt;d:RequiredDate m:type=&quot;Edm.DateTime&quot;&gt;1996-08-16T00:00:00&lt;/d:RequiredDate&gt;<br />
        &lt;d:ShippedDate m:type=&quot;Edm.DateTime&quot;&gt;1996-07-10T00:00:00&lt;/d:ShippedDate&gt;<br />
        &lt;d:ShipVia m:type=&quot;Edm.Int32&quot;&gt;1&lt;/d:ShipVia&gt;<br />
        &lt;d:Freight m:type=&quot;Edm.Decimal&quot;&gt;11.6100&lt;/d:Freight&gt;<br />
        &lt;d:ShipName&gt;Toms Spezialitäten&lt;/d:ShipName&gt;<br />
        &lt;d:ShipAddress&gt;Luisenstr. 48&lt;/d:ShipAddress&gt;<br />
        &lt;d:ShipCity&gt;Münster&lt;/d:ShipCity&gt;<br />
        &lt;d:ShipRegion m:null=&quot;true&quot; /&gt;<br />
        &lt;d:ShipPostalCode&gt;44087&lt;/d:ShipPostalCode&gt;<br />
        &lt;d:ShipCountry&gt;Germany&lt;/d:ShipCountry&gt;<br />
      &lt;/m:properties&gt;<br />
    &lt;/content&gt;<br />
  &lt;/entry&gt;<br />
  &lt;link rel=&quot;next&quot; href=&quot;http://services.odata.org/Northwind/Northwind.svc/Orders?$skiptoken=10447&quot; /&gt;<br />
&lt;/feed&gt;<br />
[/xml]</p>
<p>You can get the full data from the file <em>orders.xml</em> from the solution attached.</p>
<p>Now create a div element where we can bind the grid. </p>
<p>[html]<br />
 &lt;div id=&#8217;jqxWidget&#8217; style=&quot;font-size: 13px; font-family: Verdana; float: left;&quot;&gt;<br />
        &lt;div id=&quot;jqxgrid&quot;&gt;<br />
        &lt;/div&gt;<br />
    &lt;/div&gt;<br />
[/html]</p>
<p>Now we will define our grid as follows. </p>
<p>[js]<br />
 $(&quot;#jqxgrid&quot;).jqxGrid(<br />
            {<br />
                width: 850,<br />
                height: 450,<br />
                source: dataAdapter,<br />
                sortable: true,<br />
                selectionmode: &#8216;checkbox&#8217;,<br />
                altrows: true,<br />
                ready: function () {<br />
                    $(&#8216;#columntablejqxgrid .jqx-checkbox-default&#8217;).hide();<br />
                },<br />
                columns: [<br />
                  { text: &#8216;Ship Name&#8217;, datafield: &#8216;ShipName&#8217;, width: 250 },<br />
                  { text: &#8216;Shipped Date&#8217;, datafield: &#8216;ShippedDate&#8217;, width: 100, cellsformat: &#8216;yyyy-MM-dd&#8217; },<br />
                  { text: &#8216;Freight&#8217;, datafield: &#8216;Freight&#8217;, width: 150, cellsformat: &#8216;F2&#8217;, cellsalign: &#8216;right&#8217; },<br />
                  { text: &#8216;Ship City&#8217;, datafield: &#8216;ShipCity&#8217;, width: 150 },<br />
                  { text: &#8216;Ship Country&#8217;, datafield: &#8216;ShipCountry&#8217; }<br />
                ]<br />
            });<br />
[/js]</p>
<p>As you can see we have applied <em>dataAdapter</em> as the source, below is the definition for your data adapter. </p>
<p>[js]<br />
  var dataAdapter = new $.jqx.dataAdapter(source);<br />
[/js]</p>
<p>Now we will create the source object as follows. </p>
<p>[js]<br />
   var source =<br />
            {<br />
                datatype: &quot;xml&quot;,<br />
                datafields: [<br />
                    { name: &#8216;ShippedDate&#8217;, map: &#8216;m\\:properties&gt;d\\:ShippedDate&#8217;, type: &#8216;date&#8217; },<br />
                    { name: &#8216;Freight&#8217;, map: &#8216;m\\:properties&gt;d\\:Freight&#8217;, type: &#8216;float&#8217; },<br />
                    { name: &#8216;ShipName&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipName&#8217;, type: &#8216;string&#8217; },<br />
                    { name: &#8216;ShipAddress&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipAddress&#8217;, type: &#8216;string&#8217; },<br />
                    { name: &#8216;ShipCity&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipCity&#8217;, type: &#8216;string&#8217; },<br />
                    { name: &#8216;ShipCountry&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipCountry&#8217;, type: &#8216;string&#8217; }<br />
                ],<br />
                root: &quot;entry&quot;,<br />
                record: &quot;content&quot;,<br />
                id: &#8216;m\\:properties&gt;d\\:OrderID&#8217;,<br />
                url: url<br />
            };<br />
[/js]</p>
<p>As the grid definition is over,it is time to run our application and check whether the grid is loading fine or not. </p>
<div id="attachment_11721" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/06/Grid-with-check-box-selection-e1467177190846.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-11721" src="http://sibeeshpassion.com/wp-content/uploads/2016/06/Grid-with-check-box-selection-e1467177190846.png" alt="Grid with check box selection" width="650" height="357" class="size-full wp-image-11721" srcset="/wp-content/uploads/2016/06/Grid-with-check-box-selection-e1467177190846.png 650w, /wp-content/uploads/2016/06/Grid-with-check-box-selection-e1467177190846-300x165.png 300w, /wp-content/uploads/2016/06/Grid-with-check-box-selection-e1467177190846-400x220.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-11721" class="wp-caption-text">Grid with check box selection</p></div>
<p>what do you see? You are able to do multiple selection right? But what do we needed? A radio button selection, isn&#8217;t it? So we are suppose to able to select only one row right?. This is why, we haven&#8217;t done the needed implementation yet. Let us add some script then. </p>
<p>[js]<br />
 $(&#8216;#jqxgrid&#8217;).on(&#8216;rowselect&#8217;, function (event) {<br />
                // event arguments.<br />
                var args = event.args;<br />
                // row&#8217;s bound index.<br />
                var rowBoundIndex = args.rowindex;<br />
                var selectedIndexes = $(&#8216;#jqxgrid&#8217;).jqxGrid(&#8216;selectedrowindexes&#8217;);<br />
                for (var i = 0; i &lt; selectedIndexes.length; i++) {<br />
                    if (rowBoundIndex !== selectedIndexes[i]) {<br />
                        $(&#8216;#jqxgrid&#8217;).jqxGrid(&#8216;unselectrow&#8217;, selectedIndexes[i]);<br />
                    }<br />
                }<br />
            });<br />
[/js]</p>
<p>We are just deleting the other row selection in the event <em>rowselect</em>. Now run your application again, I am sure you will be able to select only one row at a time. </p>
<div id="attachment_11722" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/06/Grid-with-radio-button-selection-e1467177640220.png"><img decoding="async" aria-describedby="caption-attachment-11722" src="http://sibeeshpassion.com/wp-content/uploads/2016/06/Grid-with-radio-button-selection-e1467177640220.png" alt="Grid with radio button selection" width="650" height="351" class="size-full wp-image-11722" srcset="/wp-content/uploads/2016/06/Grid-with-radio-button-selection-e1467177640220.png 650w, /wp-content/uploads/2016/06/Grid-with-radio-button-selection-e1467177640220-300x162.png 300w, /wp-content/uploads/2016/06/Grid-with-radio-button-selection-e1467177640220-400x216.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-11722" class="wp-caption-text">Grid with radio button selection</p></div>
<p>Now we can see the complete code.</p>
<p><strong>Complete code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;link rel=&quot;stylesheet&quot; href=&quot;jqwidgets/styles/jqx.base.css&quot; type=&quot;text/css&quot; /&gt;</p>
<p>    &lt;script src=&quot;jquery-2.2.3.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.edit.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxcheckbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            var url = &quot;orders.xml&quot;;</p>
<p>            // prepare the data<br />
            var source =<br />
            {<br />
                datatype: &quot;xml&quot;,<br />
                datafields: [<br />
                    { name: &#8216;ShippedDate&#8217;, map: &#8216;m\\:properties&gt;d\\:ShippedDate&#8217;, type: &#8216;date&#8217; },<br />
                    { name: &#8216;Freight&#8217;, map: &#8216;m\\:properties&gt;d\\:Freight&#8217;, type: &#8216;float&#8217; },<br />
                    { name: &#8216;ShipName&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipName&#8217;, type: &#8216;string&#8217; },<br />
                    { name: &#8216;ShipAddress&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipAddress&#8217;, type: &#8216;string&#8217; },<br />
                    { name: &#8216;ShipCity&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipCity&#8217;, type: &#8216;string&#8217; },<br />
                    { name: &#8216;ShipCountry&#8217;, map: &#8216;m\\:properties&gt;d\\:ShipCountry&#8217;, type: &#8216;string&#8217; }<br />
                ],<br />
                root: &quot;entry&quot;,<br />
                record: &quot;content&quot;,<br />
                id: &#8216;m\\:properties&gt;d\\:OrderID&#8217;,<br />
                url: url<br />
            };<br />
            var dataAdapter = new $.jqx.dataAdapter(source);</p>
<p>            // create jqxgrid.<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
            {<br />
                width: 850,<br />
                height: 450,<br />
                source: dataAdapter,<br />
                sortable: true,<br />
                selectionmode: &#8216;checkbox&#8217;,<br />
                altrows: true,<br />
                ready: function () {<br />
                    $(&#8216;#columntablejqxgrid .jqx-checkbox-default&#8217;).hide();<br />
                },<br />
                columns: [<br />
                  { text: &#8216;Ship Name&#8217;, datafield: &#8216;ShipName&#8217;, width: 250 },<br />
                  { text: &#8216;Shipped Date&#8217;, datafield: &#8216;ShippedDate&#8217;, width: 100, cellsformat: &#8216;yyyy-MM-dd&#8217; },<br />
                  { text: &#8216;Freight&#8217;, datafield: &#8216;Freight&#8217;, width: 150, cellsformat: &#8216;F2&#8217;, cellsalign: &#8216;right&#8217; },<br />
                  { text: &#8216;Ship City&#8217;, datafield: &#8216;ShipCity&#8217;, width: 150 },<br />
                  { text: &#8216;Ship Country&#8217;, datafield: &#8216;ShipCountry&#8217; }<br />
                ]<br />
            });</p>
<p>            $(&#8216;#jqxgrid&#8217;).on(&#8216;rowselect&#8217;, function (event) {<br />
                // event arguments.<br />
                var args = event.args;<br />
                // row&#8217;s bound index.<br />
                var rowBoundIndex = args.rowindex;<br />
                var selectedIndexes = $(&#8216;#jqxgrid&#8217;).jqxGrid(&#8216;selectedrowindexes&#8217;);<br />
                for (var i = 0; i &lt; selectedIndexes.length; i++) {<br />
                    if (rowBoundIndex !== selectedIndexes[i]) {<br />
                        $(&#8216;#jqxgrid&#8217;).jqxGrid(&#8216;unselectrow&#8217;, selectedIndexes[i]);<br />
                    }<br />
                }<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body class=&#8217;default&#8217;&gt;<br />
    &lt;div id=&#8217;jqxWidget&#8217; style=&quot;font-size: 13px; font-family: Verdana; float: left;&quot;&gt;<br />
        &lt;div id=&quot;jqxgrid&quot;&gt;<br />
        &lt;/div&gt;<br />
    &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/implement-radio-button-selection-in-jqwidgets-jqxgrid-using-checkbox/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Dynamically Apply Colour Coding in Grid With Dynamic Headers And Data</title>
		<link>https://mail.sibeeshpassion.com/dynamically-apply-colour-coding-in-grid-with-dynamic-headers-and-data/</link>
					<comments>https://mail.sibeeshpassion.com/dynamically-apply-colour-coding-in-grid-with-dynamic-headers-and-data/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 16 Feb 2016 07:33:54 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[cellsrenderer]]></category>
		<category><![CDATA[Colour Code In Grid]]></category>
		<category><![CDATA[dataAdapter]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=11229</guid>

					<description><![CDATA[In this post we will see how we can apply colour coding dynamically to jQWidgets jQXGrid. Normally a grid control can be used when you need to formulate the data either in row wise or column wise. Here in this pose we will discuss how to differentiate some rows of the grid from the other by applying some conditions over the values dynamically. We are taking an HTML table as the data source and in the client side we will be looping through each columns and rows. If you are new to JQX Grid, you can see some tips here. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can apply colour coding dynamically to <a href="http://sibeeshpassion.com/category/products/jqwidgets/" target="_blank">jQWidgets </a><a href="http://sibeeshpassion.com/category/products/jqwidgets/jqx-grid/" target="_blank">jQXGrid</a>. Normally a grid control can be used when you need to formulate the data either in row wise or column wise. Here in this pose we will discuss how to differentiate some rows of the grid from the other by applying some conditions over the values dynamically. We are taking an HTML table as the data source and in the client side we will be looping through each columns and rows. If you are new to JQX Grid, you can see some tips <em><a href="http://sibeeshpassion.com/tag/jqx-grid/" target="_blank">here</a></em>. I hope you will like this. </p>
<p><strong>Background</strong></p>
<p>If you are aware of the header column names and the data (Static data), you can apply the colour coding in a simple way as shown in this <a href="http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/gridcellclass.htm" target="_blank">link</a>. There we are using a property called <em>cellclassname</em> to fire an external function which returns the coloured HTML in return. </p>
<p>But in my case, the situation was different. The data source (HTML table here) was dynamic, hence I could not predict the header names and the data. As you know, to load a jQWidget JQX Grid, there you need the following things as mandatory. </p>
<li>datafields</li>
<li>columns</li>
<li>localdata or server side data</li>
<p>So to create/format the above mentioned properties, I am using an another way which we will discuss in this post. </p>
<p><strong>Using the code</strong></p>
<p>First of all, load the needed references. You can download the needed files from <a href="http://www.jqwidgets.com/download/" target="_blank">here</a>.</p>
<p>[html]<br />
 &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;<br />
[/html]</p>
<p>Now, we will create the HTML data. To make the processes easy, here I am going to paste a static HTML table(This table was dynamic for me).</p>
<p>[html]<br />
&lt;table id=&quot;initialTable&quot; style=&quot;width: 300px;display:none;&quot;&gt;<br />
        &lt;thead&gt;<br />
            &lt;tr&gt;<br />
                &lt;th&gt;Firstname<br />
                &lt;/th&gt;<br />
                &lt;th&gt;Lastname<br />
                &lt;/th&gt;<br />
                &lt;th&gt;Debits<br />
                &lt;/th&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/thead&gt;<br />
        &lt;tbody&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/tbody&gt;<br />
    &lt;/table&gt;<br />
[/html]</p>
<p>Then it is time to say where do you need to bind the grid.</p>
<p>[html]<br />
&lt;div id=&#8217;jqxWidget&#8217; style=&quot;font-size: 13px; font-family: Verdana; float: left;&quot;&gt;<br />
        &lt;div id=&quot;jqxgrid&quot;&gt;<br />
        &lt;/div&gt;<br />
    &lt;/div&gt;<br />
[/html]</p>
<p>Now we will define our grid as follows. </p>
<p>[js]<br />
$(&quot;#jqxgrid&quot;).jqxGrid(<br />
            {<br />
                width: 850,<br />
                autoheight: true,<br />
                source: dataAdapter,<br />
                columns: columnsArray,<br />
                pageable: true,<br />
                sortable: true,<br />
                filterable: true<br />
            });<br />
[/js]</p>
<p>As you can see we have applied <em>dataAdapter</em> as the source, below is the definition for your data adapter. </p>
<p>[js]<br />
  var dataAdapter = new $.jqx.dataAdapter(source);<br />
[/js]</p>
<p>Now we will create the source object as follows. </p>
<p>[js]<br />
 var source =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: dataFieldsArray,<br />
                localdata: data<br />
            };<br />
[/js]</p>
<p>As the grid definition is over, we can create our data, datafields, columns. Shall we? As I said earlier, our data source is a HTML table. We are looping through the trs to create the data and ths to create the datafields and columns. </p>
<p>[js]<br />
// select rows.<br />
            var rows = $(&quot;#initialTable tbody tr&quot;);<br />
            // select columns.<br />
            var columns = $(&quot;#initialTable thead th&quot;);<br />
            var data = [];<br />
            var dataFieldsArray = [];<br />
            var columnsArray = [];<br />
            for (var i = 0; i &lt; rows.length; i++) {<br />
                var row = rows&amp;#91;i&amp;#93;;<br />
                var datarow = {};<br />
                for (var j = 0; j &lt; columns.length; j++) {<br />
                    // get column&#8217;s title.<br />
                    var columnName = $.trim($(columns&amp;#91;j&amp;#93;).text());<br />
                    // select cell.<br />
                    var cell = $(row).find(&#8216;td:eq(&#8216; + j + &#8216;)&#8217;);<br />
                    var type = &#8216;string&#8217;;<br />
                    var format = &#8221;;<br />
                    var cellsalign = &#8216;left&#8217;;<br />
                    if (!isNaN(cell.text())) {<br />
                        type = &#8216;number&#8217;;<br />
                        format = &#8216;d&#8217;;<br />
                        cellsalign = &#8216;right&#8217;;<br />
                    }<br />
                    datarow&amp;#91;columnName&amp;#93; = $.trim(cell.text());<br />
                    if (i === 0) {<br />
                        dataFieldsArray.push({ name: columnName, type: type });<br />
                        columnsArray.push({ name: columnName, dataField: columnName, cellsrenderer: cellsrenderer, cellsformat: format, cellsalign: cellsalign });<br />
                    }<br />
                }<br />
                data&amp;#91;data.length&amp;#93; = datarow;<br />
            }<br />
&amp;#91;/js&amp;#93;</p>
<p>Have you noticed that when we push the the items to the &lt;em&gt;columnsArray&lt;/em&gt; we are calling the function &lt;em&gt;cellsrenderer&lt;/em&gt;. This &lt;em&gt;cellsrenderer&lt;/em&gt; function returns the HTML with coloured data as we expected. </p>
<p>[js]<br />
 var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {<br />
                if (parseFloat(rowdata.Debits) &lt; 30) {<br />
                    return &#8216;&lt;span style=&quot;margin: 4px; float: &#8216; + columnproperties.cellsalign + &#8216;; color: #ff0000;&quot;&gt;&#8217; + value + &#8216;&lt;/span&gt;&#8217;;<br />
                } else {<br />
                    return &#8216;&lt;span style=&quot;margin: 4px; float: &#8216; + columnproperties.cellsalign + &#8216;; color: #00ff00;&quot;&gt;&#8217; + value + &#8216;&lt;/span&gt;&#8217;;<br />
                }<br />
            };<br />
[/js]</p>
<p>Here in this function we will get the needed things like row, columnfield, value, defaulthtml, columnproperties, rowdata as parameters and we checks for the condition <em>rowdata.Debits<30</em>, if it is true we will apply the colour #ff0000 or #00ff00. </p>
<p>Once the formatting is done, we are pushing the items to the arrays. Now we can see the complete code.</p>
<p><strong>Complete code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;</p>
<p>    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {<br />
                if (parseFloat(rowdata.Debits) &lt; 30) {<br />
                    return &#8216;&lt;span style=&quot;margin: 4px; float: &#8216; + columnproperties.cellsalign + &#8216;; color: #ff0000;&quot;&gt;&#8217; + value + &#8216;&lt;/span&gt;&#8217;;<br />
                } else {<br />
                    return &#8216;&lt;span style=&quot;margin: 4px; float: &#8216; + columnproperties.cellsalign + &#8216;; color: #00ff00;&quot;&gt;&#8217; + value + &#8216;&lt;/span&gt;&#8217;;<br />
                }<br />
            };</p>
<p>            // select rows.<br />
            var rows = $(&quot;#initialTable tbody tr&quot;);<br />
            // select columns.<br />
            var columns = $(&quot;#initialTable thead th&quot;);<br />
            var data = [];<br />
            var dataFieldsArray = [];<br />
            var columnsArray = [];<br />
            for (var i = 0; i &lt; rows.length; i++) {<br />
                var row = rows&amp;#91;i&amp;#93;;<br />
                var datarow = {};<br />
                for (var j = 0; j &lt; columns.length; j++) {<br />
                    // get column&#8217;s title.<br />
                    var columnName = $.trim($(columns&amp;#91;j&amp;#93;).text());<br />
                    // select cell.<br />
                    var cell = $(row).find(&#8216;td:eq(&#8216; + j + &#8216;)&#8217;);<br />
                    var type = &#8216;string&#8217;;<br />
                    var format = &#8221;;<br />
                    var cellsalign = &#8216;left&#8217;;<br />
                    if (!isNaN(cell.text())) {<br />
                        type = &#8216;number&#8217;;<br />
                        format = &#8216;d&#8217;;<br />
                        cellsalign = &#8216;right&#8217;;<br />
                    }<br />
                    datarow&amp;#91;columnName&amp;#93; = $.trim(cell.text());<br />
                    if (i === 0) {<br />
                        dataFieldsArray.push({ name: columnName, type: type });<br />
                        columnsArray.push({ name: columnName, dataField: columnName, cellsrenderer: cellsrenderer, cellsformat: format, cellsalign: cellsalign });<br />
                    }<br />
                }<br />
                data&amp;#91;data.length&amp;#93; = datarow;<br />
            }</p>
<p>            // prepare the data<br />
            var source =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: dataFieldsArray,<br />
                localdata: data<br />
            };<br />
            var dataAdapter = new $.jqx.dataAdapter(source);</p>
<p>            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
            {<br />
                width: 850,<br />
                autoheight: true,<br />
                source: dataAdapter,<br />
                columns: columnsArray,<br />
                pageable: true,<br />
                sortable: true,<br />
                filterable: true<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body class=&#8217;default&#8217;&gt;<br />
    &lt;table id=&quot;initialTable&quot; style=&quot;width: 300px;display:none;&quot;&gt;<br />
        &lt;thead&gt;<br />
            &lt;tr&gt;<br />
                &lt;th&gt;Firstname<br />
                &lt;/th&gt;<br />
                &lt;th&gt;Lastname<br />
                &lt;/th&gt;<br />
                &lt;th&gt;Debits<br />
                &lt;/th&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/thead&gt;<br />
        &lt;tbody&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Eve<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Jackson<br />
                &lt;/td&gt;<br />
                &lt;td&gt;94<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Clara<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Oswald<br />
                &lt;/td&gt;<br />
                &lt;td&gt;17<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
                &lt;td&gt;Benedict<br />
                &lt;/td&gt;<br />
                &lt;td&gt;Mason<br />
                &lt;/td&gt;<br />
                &lt;td&gt;33<br />
                &lt;/td&gt;<br />
            &lt;/tr&gt;<br />
        &lt;/tbody&gt;<br />
    &lt;/table&gt;</p>
<p>    &lt;p style=&quot;font-family: Verdana;&quot;&gt;<br />
        Dynamically apply colour coding in Grid<br />
    &lt;/p&gt;<br />
    &lt;div id=&#8217;jqxWidget&#8217; style=&quot;font-size: 13px; font-family: Verdana; float: left;&quot;&gt;<br />
        &lt;div id=&quot;jqxgrid&quot;&gt;<br />
        &lt;/div&gt;<br />
    &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Output</strong></p>
<div id="attachment_11232" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/02/Dynamically-apply-colour-coding-in-Grid-e1455607915795.png"><img decoding="async" aria-describedby="caption-attachment-11232" src="http://sibeeshpassion.com/wp-content/uploads/2016/02/Dynamically-apply-colour-coding-in-Grid-e1455607915795.png" alt="Dynamically apply colour coding in Grid" width="650" height="285" class="size-full wp-image-11232" srcset="/wp-content/uploads/2016/02/Dynamically-apply-colour-coding-in-Grid-e1455607915795.png 650w, /wp-content/uploads/2016/02/Dynamically-apply-colour-coding-in-Grid-e1455607915795-300x132.png 300w, /wp-content/uploads/2016/02/Dynamically-apply-colour-coding-in-Grid-e1455607915795-400x175.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-11232" class="wp-caption-text">Dynamically apply colour coding in Grid</p></div>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/dynamically-apply-colour-coding-in-grid-with-dynamic-headers-and-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>a href Columns In Grid</title>
		<link>https://mail.sibeeshpassion.com/a-href-columns-in-grid/</link>
					<comments>https://mail.sibeeshpassion.com/a-href-columns-in-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 11 Nov 2015 14:18:54 +0000</pubDate>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[a href Columns In Grid]]></category>
		<category><![CDATA[cellsrenderer]]></category>
		<category><![CDATA[JQXGrid]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10959</guid>

					<description><![CDATA[In this post we will how we can customize a column in jQWidget jQX Grid. We will make one of the columns values to a hreaf tag. First we will load the grid from the a custom json data and then we will use cellsrenderer function to format the columns values. I hope you will like this. Background We all works in grid controls. Sometimes you may need to customize the grid and its column values. Here I am giving you custom demo of the same. In this article we are going to customize the grid column contents to a [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will how we can customize a column in <a href="http://sibeeshpassion.com/category/jqwidgets/" target="_blank">jQWidget</a> jQX Grid. We will make one of the columns values to a hreaf tag. First we will load the grid from the a custom json data and then we will use cellsrenderer function to format the columns values. I hope you will like this. </p>
<p><strong>Background</strong></p>
<p>We all works in grid controls. Sometimes you may need to customize the grid and its column values. Here I am giving you custom demo of the same. In this article we are going to customize the grid column contents to a href tags.</p>
<p><strong>Using the code</strong></p>
<p>To show this demo, I am using jQWidget jQX Grid control. If you are new to jQX Grid, you can find out some introduction here: <a href="http://sibeeshpassion.com/category/products/jqwidgets/" target="_blank">jQWidget JQX Grid</a></p>
<p>Now we are going to load the grid first. I hope you have already checked how to load the grid. Please see the below code. </p>
<p><em>Create an HTML page</em></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Href Columns In Grid &#8211; Sibeesh Passion&lt;/title&gt;<br />
   &lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;h3&gt;Href Columns In Grid &#8211; Sibeesh Passion&lt;/h3&gt;<br />
    &lt;br /&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p><em>Add the needed references</em></p>
<p>[html]<br />
 &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;<br />
[/html]</p>
<p>Here comes the main part.</p>
<p><strong>Grid Settings or Grid Initialization</strong></p>
<p>[js]<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            var columntohref = function (row, column, value) {<br />
                if (value.indexOf(&#8216;#&#8217;) != -1) {<br />
                    value = value.substring(0, value.indexOf(&#8216;#&#8217;));<br />
                }<br />
                var format = { target: &#8216;&quot;_blank&quot;&#8217; };<br />
                var html = $.jqx.dataFormat.formatlink(value, format);<br />
                return html;<br />
            }<br />
            var data =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: [{ &quot;name&quot;: &quot;LinkName&quot;, &quot;type&quot;: &quot;string&quot; }, { &quot;name&quot;: &quot;Link&quot;, &quot;type&quot;: &quot;string&quot; }],<br />
                url: &quot;CustomData.txt&quot;<br />
            };<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;LinkName&quot;, &quot;dataField&quot;: &quot;LinkName&quot;, width: &quot;300&quot; }, { &quot;text&quot;: &quot;Link&quot;, &quot;dataField&quot;: &quot;Link&quot;, cellsrenderer: columntohref, width: &quot;300&quot; }]<br />
                  });<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p><strong>Sample data</strong></p>
<p>Following is the contents of <em>CustomData.txt</em></p>
<p>[js]<br />
[{&quot;LinkName&quot;:&quot;Sibeesh Passion&quot;,&quot;Link&quot;:&quot;http://www.sibeeshpassion.com&quot;},{&quot;LinkName&quot;:&quot;C-Sharp Corner&quot;,&quot;Link&quot;:&quot;http://www.c-sharpcorner.com&quot;},{&quot;LinkName&quot;:&quot;Facebook&quot;,&quot;Link&quot;:&quot;http://www.fb.com&quot;},{&quot;LinkName&quot;:&quot;Google&quot;,&quot;Link&quot;:&quot;http://www.google.com&quot;}]<br />
[/js]</p>
<p>As you can find out in the above code we are using cellsrenderer property to call the function <em>columntohref</em> which does the formatting. We are formatting the data as below ,</p>
<p>[js]<br />
$.jqx.dataFormat.formatlink(value, format)<br />
[/js]</p>
<p>Shall we check our output now? </p>
<p><strong>Output</strong></p>
<div id="attachment_10960" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/11/href_columns_in_grid-e1447251398918.png"><img decoding="async" aria-describedby="caption-attachment-10960" src="http://sibeeshpassion.com/wp-content/uploads/2015/11/href_columns_in_grid-e1447251398918.png" alt="Column values to a href" width="650" height="497" class="size-full wp-image-10960" srcset="/wp-content/uploads/2015/11/href_columns_in_grid-e1447251398918.png 650w, /wp-content/uploads/2015/11/href_columns_in_grid-e1447251398918-300x229.png 300w, /wp-content/uploads/2015/11/href_columns_in_grid-e1447251398918-400x306.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10960" class="wp-caption-text">Column values to a href</p></div>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Href Columns In Grid &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;</p>
<p>    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            var columntohref = function (row, column, value) {<br />
                if (value.indexOf(&#8216;#&#8217;) != -1) {<br />
                    value = value.substring(0, value.indexOf(&#8216;#&#8217;));<br />
                }<br />
                var format = { target: &#8216;&quot;_blank&quot;&#8217; };<br />
                var html = $.jqx.dataFormat.formatlink(value, format);<br />
                return html;<br />
            }<br />
            var data =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: [{ &quot;name&quot;: &quot;LinkName&quot;, &quot;type&quot;: &quot;string&quot; }, { &quot;name&quot;: &quot;Link&quot;, &quot;type&quot;: &quot;string&quot; }],<br />
                url: &quot;CustomData.txt&quot;<br />
            };<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;LinkName&quot;, &quot;dataField&quot;: &quot;LinkName&quot;, width: &quot;300&quot; }, { &quot;text&quot;: &quot;Link&quot;, &quot;dataField&quot;: &quot;Link&quot;, cellsrenderer: columntohref, width: &quot;300&quot; }]<br />
                  });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body class=&#8217;default&#8217;&gt;<br />
    &lt;h2&gt;Href Columns In Grid &#8211; Sibeesh Passion&lt;/h2&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/a-href-columns-in-grid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Load Data To Grid On Sroll</title>
		<link>https://mail.sibeeshpassion.com/load-data-to-grid-on-sroll/</link>
					<comments>https://mail.sibeeshpassion.com/load-data-to-grid-on-sroll/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 02 Nov 2015 06:09:36 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[jQWidget]]></category>
		<category><![CDATA[Load data dynamically]]></category>
		<category><![CDATA[Load Data To Grid On Sroll]]></category>
		<category><![CDATA[rendergridrows]]></category>
		<category><![CDATA[virtualmode]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10886</guid>

					<description><![CDATA[In this post we will discuss about how we can load data to a grid on scroll event. As you all know Grid is a main control in every dashboard. Every company uses a grid control for showing reports or any kind of data. Hence it is widely used, it is important that the grid must be loaded faster. So the performance of the grid control matters a lot. Isn&#8217;t it? Here in this post we are going to do a task which will increase the performance of the grid since we are going to load the data as per [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will discuss about how we can load data to a grid on scroll event. As you all know Grid is a main control in every dashboard. Every company uses a grid control for showing reports or any kind of data. Hence it is widely used, it is important that the grid must be loaded faster. So the performance of the grid control matters a lot. Isn&#8217;t it? Here in this post we are going to do a task which will increase the performance of the grid since we are going to load the data as per user request (on scrolling down). Sounds cool?. Normally what we do is, we will load all the data to the grid in a head shot, the problem in this manner is, it will take ages to load the full data to grid. Hence the user will close your application and the won&#8217;t return back. That is sad thing right? So we will concentrate on the performance part now. I hope you will like this. </p>
<p><strong>Background</strong></p>
<p>I am working in a dashboard application. So for me performance was the main criteria to take care. We have used server side paging to improve the performance. This I will share in my next article. Now we will try to load a client side data on demand. Let us say when ever user scroll down. Sounds fine? Ok let us start then.</p>
<p><strong>Using the code</strong></p>
<p>To show this demo, I am using jQWidget jQX Grid control. If you are new to jQX Grid, you can find out some introduction here: <a href="http://sibeeshpassion.com/category/products/jqwidgets/" target="_blank">jQWidget JQX Grid</a></p>
<p>Now we are going to load the grid first. I hope you have already checked how to load the grid. Please see the below code. </p>
<p><em>Create an HTML page</em></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Load Data To Grid On Scroll  &#8211; Sibeesh Passion&lt;/title&gt;<br />
   &lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;h3&gt;Load Data To Grid On Scroll  &#8211; Sibeesh Passion&lt;/h3&gt;<br />
    &lt;br /&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p><em>Add the needed references</em></p>
<p>[html]<br />
 &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;<br />
[/html]</p>
<p>Here comes the main part.</p>
<p><strong>Grid Settings or Grid Initialization</strong></p>
<p>[js]<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
         $(document).ready(function () {<br />
             // prepare the data<br />
             var data = new Array();<br />
             var firstNames =<br />
             [<br />
                 &quot;Sibeesh&quot;, &quot;Ajay&quot;, &quot;Ansary&quot;, &quot;Aghil&quot;, &quot;Shanto&quot;, &quot;Libin&quot;, &quot;Vignesh&quot;, &quot;Ramesh&quot;, &quot;Sathian&quot;, &quot;Elango&quot;, &quot;karthik&quot;<br />
             ];</p>
<p>             var lastNames =<br />
             [<br />
                 &quot;Venu&quot;, &quot;Bhasy&quot;, &quot;Rasheed&quot;, &quot;Ghosh&quot;, &quot;Thomas&quot;, &quot;Lawrence&quot;, &quot;Vicky&quot;, &quot;K&quot;, &quot;K&quot;, &quot;S&quot;, &quot;Srinivasan&quot;<br />
             ];</p>
<p>             var productNames =<br />
             [<br />
                 &quot;Shoe&quot;, &quot;Sandals&quot;, &quot;Shampoo&quot;, &quot;Soap&quot;, &quot;Hair Lotion&quot;, &quot;Creams&quot;, &quot;Bags&quot;, &quot;Watch&quot;, &quot;Books&quot;, &quot;Mobile&quot;, &quot;Tab&quot;, &quot;Laptop&quot;<br />
             ];</p>
<p>             var priceValues =<br />
             [<br />
                 &quot;2.25&quot;, &quot;1.5&quot;, &quot;3.0&quot;, &quot;3.3&quot;, &quot;4.5&quot;, &quot;3.6&quot;, &quot;3.8&quot;, &quot;2.5&quot;, &quot;5.0&quot;, &quot;20.75&quot;, &quot;13.25&quot;, &quot;124.0&quot;<br />
             ];</p>
<p>             // generate sample data.<br />
             var generatedata = function (startindex, endindex) {<br />
                 var data = {};<br />
                 for (var i = startindex; i &lt; endindex; i++) {<br />
                     var row = {};<br />
                     var productindex = Math.floor(Math.random() * productNames.length);<br />
                     var price = parseFloat(priceValues[productindex]);<br />
                     var quantity = 1 + Math.round(Math.random() * 10);</p>
<p>                     row[&quot;id&quot;] = i;<br />
                     row[&quot;firstname&quot;] = firstNames[Math.floor(Math.random() * firstNames.length)];<br />
                     row[&quot;lastname&quot;] = lastNames[Math.floor(Math.random() * lastNames.length)];<br />
                     row[&quot;productname&quot;] = productNames[productindex];<br />
                     row[&quot;price&quot;] = price;<br />
                     row[&quot;quantity&quot;] = quantity;<br />
                     row[&quot;total&quot;] = price * quantity;</p>
<p>                     data[i] = row;<br />
                 }<br />
                 return data;<br />
             }</p>
<p>             var source =<br />
             {<br />
                 datatype: &quot;array&quot;,<br />
                 localdata: {},<br />
                 totalrecords: 1000000<br />
             };</p>
<p>             // load virtual data.<br />
             var rendergridrows = function (params) {<br />
                 var data = generatedata(params.startindex, params.endindex);<br />
                 return data;<br />
             }<br />
             var dataAdapter = new $.jqx.dataAdapter(source);</p>
<p>             $(&quot;#jqxgrid&quot;).jqxGrid(<br />
             {<br />
                 width: 850,<br />
                 source: dataAdapter,<br />
                 virtualmode: true,<br />
                 rendergridrows: rendergridrows,<br />
                 columns: [<br />
                     { text: &#8216;Id&#8217;, datafield: &#8216;id&#8217;, width: 100 },<br />
                     { text: &#8216;First Name&#8217;, datafield: &#8216;firstname&#8217;, width: 120 },<br />
                     { text: &#8216;Last Name&#8217;, datafield: &#8216;lastname&#8217;, width: 120 },<br />
                     { text: &#8216;Product&#8217;, datafield: &#8216;productname&#8217;, width: 180 },<br />
                     { text: &#8216;Quantity&#8217;, datafield: &#8216;quantity&#8217;, width: 80, cellsalign: &#8216;right&#8217; },<br />
                     { text: &#8216;Unit Price&#8217;, datafield: &#8216;price&#8217;, width: 90, cellsalign: &#8216;right&#8217;, cellsformat: &#8216;c2&#8217; },<br />
                     { text: &#8216;Total&#8217;, datafield: &#8216;total&#8217;, cellsalign: &#8216;right&#8217;, cellsformat: &#8216;c2&#8217; }<br />
                 ]<br />
             });<br />
         });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>As you can find out in the above code we are generating the data dynamically using a <a href="http://sibeeshpassion.com/function-declaration-and-function-expression/" target="_blank">function declaration</a> <em>generatedata</em>. </p>
<p>Have you noticed that in the grid settings we have given <em>virtualmode: true</em>. This is very important. This property is meant to be used for handling the dynamic data in grid. </p>
<p>And another property you must be aware of is <em>rendergridrows: rendergridrows</em>. This means, we are rendering the grid data on demand. Like when user change the pager or scroll. So we are going to call our <em>generatedata</em> function in the <em>rendergridrows</em>. We are passing the start index and end index to the function, so that the dynamic data won&#8217;t be repeated.</p>
<p>[js]<br />
var rendergridrows = function (params) {<br />
                 var data = generatedata(params.startindex, params.endindex);<br />
                 return data;<br />
             }<br />
[/js]</p>
<p>Once the data is ready, we will pass it to the source object and source object to dataAdapter and finally dataAdapter to grid.</p>
<p>Shall we check our output now? </p>
<p><strong>Output</strong></p>
<div id="attachment_10887" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll-e1446444313182.png"><img decoding="async" aria-describedby="caption-attachment-10887" src="http://sibeeshpassion.com/wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll-e1446444313182.png" alt="Load Data On Scroll" width="650" height="369" class="size-full wp-image-10887" srcset="/wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll-e1446444313182.png 650w, /wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll-e1446444313182-300x170.png 300w, /wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll-e1446444313182-400x227.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10887" class="wp-caption-text">Load Data On Scroll</p></div>
<div id="attachment_10888" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll_1-e1446444357826.png"><img decoding="async" aria-describedby="caption-attachment-10888" src="http://sibeeshpassion.com/wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll_1-e1446444357826.png" alt="Load Data On Scroll" width="650" height="359" class="size-full wp-image-10888" srcset="/wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll_1-e1446444357826.png 650w, /wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll_1-e1446444357826-300x166.png 300w, /wp-content/uploads/2015/11/Load_Data_In_Grid_On_Scroll_1-e1446444357826-400x221.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10888" class="wp-caption-text">Load Data On Scroll</p></div>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Load Data To Grid On Scroll  &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;</p>
<p>     &lt;script type=&quot;text/javascript&quot;&gt;<br />
         $(document).ready(function () {<br />
             // prepare the data<br />
             var data = new Array();<br />
             var firstNames =<br />
             [<br />
                 &quot;Sibeesh&quot;, &quot;Ajay&quot;, &quot;Ansary&quot;, &quot;Aghil&quot;, &quot;Shanto&quot;, &quot;Libin&quot;, &quot;Vignesh&quot;, &quot;Ramesh&quot;, &quot;Sathian&quot;, &quot;Elango&quot;, &quot;karthik&quot;<br />
             ];</p>
<p>             var lastNames =<br />
             [<br />
                 &quot;Venu&quot;, &quot;Bhasy&quot;, &quot;Rasheed&quot;, &quot;Ghosh&quot;, &quot;Thomas&quot;, &quot;Lawrence&quot;, &quot;Vicky&quot;, &quot;K&quot;, &quot;K&quot;, &quot;S&quot;, &quot;Srinivasan&quot;<br />
             ];</p>
<p>             var productNames =<br />
             [<br />
                 &quot;Shoe&quot;, &quot;Sandals&quot;, &quot;Shampoo&quot;, &quot;Soap&quot;, &quot;Hair Lotion&quot;, &quot;Creams&quot;, &quot;Bags&quot;, &quot;Watch&quot;, &quot;Books&quot;, &quot;Mobile&quot;, &quot;Tab&quot;, &quot;Laptop&quot;<br />
             ];</p>
<p>             var priceValues =<br />
             [<br />
                 &quot;2.25&quot;, &quot;1.5&quot;, &quot;3.0&quot;, &quot;3.3&quot;, &quot;4.5&quot;, &quot;3.6&quot;, &quot;3.8&quot;, &quot;2.5&quot;, &quot;5.0&quot;, &quot;20.75&quot;, &quot;13.25&quot;, &quot;124.0&quot;<br />
             ];</p>
<p>             var generatedata = function (startindex, endindex) {<br />
                 var data = {};<br />
                 for (var i = startindex; i &lt; endindex; i++) {<br />
                     var row = {};<br />
                     var productindex = Math.floor(Math.random() * productNames.length);<br />
                     var price = parseFloat(priceValues[productindex]);<br />
                     var quantity = 1 + Math.round(Math.random() * 10);</p>
<p>                     row[&quot;id&quot;] = i;<br />
                     row[&quot;firstname&quot;] = firstNames[Math.floor(Math.random() * firstNames.length)];<br />
                     row[&quot;lastname&quot;] = lastNames[Math.floor(Math.random() * lastNames.length)];<br />
                     row[&quot;productname&quot;] = productNames[productindex];<br />
                     row[&quot;price&quot;] = price;<br />
                     row[&quot;quantity&quot;] = quantity;<br />
                     row[&quot;total&quot;] = price * quantity;</p>
<p>                     data[i] = row;<br />
                 }<br />
                 return data;<br />
             }</p>
<p>             var source =<br />
             {<br />
                 datatype: &quot;array&quot;,<br />
                 localdata: {},<br />
                 totalrecords: 1000000<br />
             };</p>
<p>             // load virtual data.<br />
             var rendergridrows = function (params) {<br />
                 var data = generatedata(params.startindex, params.endindex);<br />
                 return data;<br />
             }<br />
             var dataAdapter = new $.jqx.dataAdapter(source);</p>
<p>             $(&quot;#jqxgrid&quot;).jqxGrid(<br />
             {<br />
                 width: 850,<br />
                 source: dataAdapter,<br />
                 virtualmode: true,<br />
                 rendergridrows: rendergridrows,<br />
                 columns: [<br />
                     { text: &#8216;Id&#8217;, datafield: &#8216;id&#8217;, width: 100 },<br />
                     { text: &#8216;First Name&#8217;, datafield: &#8216;firstname&#8217;, width: 120 },<br />
                     { text: &#8216;Last Name&#8217;, datafield: &#8216;lastname&#8217;, width: 120 },<br />
                     { text: &#8216;Product&#8217;, datafield: &#8216;productname&#8217;, width: 180 },<br />
                     { text: &#8216;Quantity&#8217;, datafield: &#8216;quantity&#8217;, width: 80, cellsalign: &#8216;right&#8217; },<br />
                     { text: &#8216;Unit Price&#8217;, datafield: &#8216;price&#8217;, width: 90, cellsalign: &#8216;right&#8217;, cellsformat: &#8216;c2&#8217; },<br />
                     { text: &#8216;Total&#8217;, datafield: &#8216;total&#8217;, cellsalign: &#8216;right&#8217;, cellsformat: &#8216;c2&#8217; }<br />
                 ]<br />
             });<br />
         });<br />
    &lt;/script&gt;</p>
<p>&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;h3&gt;Load Data To Grid On Scroll  &#8211; Sibeesh Passion&lt;/h3&gt;<br />
    &lt;br /&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/load-data-to-grid-on-sroll/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Change Themes Dynamically In Grid</title>
		<link>https://mail.sibeeshpassion.com/change-themes-dynamically-in-grid/</link>
					<comments>https://mail.sibeeshpassion.com/change-themes-dynamically-in-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 28 Oct 2015 13:40:51 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[Apply Themes In Grid]]></category>
		<category><![CDATA[Change Themes Dynamically]]></category>
		<category><![CDATA[Disable The Stylesheets]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10855</guid>

					<description><![CDATA[In this post we will see how we can Change Themes Dynamically In Grid . I recently came across a situation to change the grid&#8217;s theme dynamically, when ever user select any theme. So I have done this requirement by using some in-built functionalities of jQWidget JQX grid. Here I am going to share you that. I hope you will like it. To load a grid from a JSON, you can follows the steps as discussed in this article: Load jQWidget JQX Grid From JSON Background If you are new to JQWidget JQX Grid, Please find out here: http://sibeeshpassion.com/category/jqwidgets/ Download [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can Change Themes Dynamically In Grid . I recently came across a situation to change the grid&#8217;s theme dynamically, when ever user select any theme. So I have done this requirement by using some in-built functionalities of jQWidget JQX grid. Here I am going to share you that. I hope you will like it.</p>
<p>To load a grid from a JSON, you can follows the steps as discussed in this article: <a href="http://sibeeshpassion.com/bind-json-data-to-jqwidget-jqx-grid/">Load jQWidget JQX Grid From JSON</a></p>
<p><strong>Background</strong></p>
<p>If you are new to JQWidget JQX Grid, Please find out here: <a href="http://sibeeshpassion.com/category/jqwidgets/" target="_blank">http://sibeeshpassion.com/category/jqwidgets/</a></p>
<p><strong>Download the Source Code</strong></p>
<p>Please download the source code from here: <a href="http://sibeeshpassion.com/download/changetheme.rar" target="_blank">Change Themes Dynamically</a></p>
<p><strong>Using the code</strong></p>
<p>I hope you have implemented your grid as shown in that article. Now I guess your page will be looking like this.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Change Themes Dynamically In Grid &#8211; Sibeesh Passion&lt;/title&gt;<br />
   &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;</p>
<p>    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            // prepare the data<br />
            var data =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: [{ &quot;name&quot;: &quot;AreaCode&quot;, &quot;type&quot;: &quot;string&quot; }, { &quot;name&quot;: &quot;Revenue&quot;, &quot;type&quot;: &quot;number&quot; }],<br />
                url: &quot;jsonData.txt&quot;<br />
            };<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;Area Code&quot;, &quot;dataField&quot;: &quot;AreaCode&quot;, &quot;cellsalign&quot;: &quot;left&quot;, &quot;cellsformat&quot;: &quot;d&quot; }, { &quot;text&quot;: &quot;Revenue&quot;, &quot;dataField&quot;: &quot;Revenue&quot;, &quot;cellsalign&quot;: &quot;right&quot;, &quot;cellsformat&quot;: &quot;c2&quot; }],<br />
                  });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;h3&gt;Change Themes Dynamically In Grid &#8211; Sibeesh Passion&lt;/h3&gt;<br />
    &lt;br /&gt;<br />
    &lt;div id=&#8217;jqxWidget&#8217; style=&quot;float: left; width: 99.9%;&quot;&gt;<br />
        &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
    &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p>Now let us make sure that grid is working fine. Please run your project. </p>
<div id="attachment_10856" style="width: 620px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid.png"><img decoding="async" aria-describedby="caption-attachment-10856" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid.png" alt="Change Themes Dynamically In Grid " width="610" height="470" class="size-full wp-image-10856" srcset="/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid.png 610w, /wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid-300x231.png 300w, /wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid-400x308.png 400w" sizes="(max-width: 610px) 100vw, 610px" /></a><p id="caption-attachment-10856" class="wp-caption-text">Change Themes Dynamically In Grid</p></div>
<p>Cool, so grid is loaded. Now need to add a select control in which we are going to load theme names so that user can select the theme and apply. Is that fine?</p>
<p>[html]<br />
  &lt;select id=&quot;selectOptions&quot; onchange=&quot;applyNewCSS()&quot;&gt;<br />
        &lt;option value=&quot;0&quot;&gt;Select Template&lt;/option&gt;<br />
        &lt;option value=&quot;metro&quot;&gt;metro&lt;/option&gt;<br />
        &lt;option value=&quot;office&quot;&gt;office&lt;/option&gt;<br />
        &lt;option value=&quot;orange&quot;&gt;orange&lt;/option&gt;<br />
        &lt;option value=&quot;energyblue&quot;&gt;energyblue&lt;/option&gt;<br />
        &lt;option value=&quot;darkblue&quot;&gt;darkblue&lt;/option&gt;<br />
        &lt;option value=&quot;shinyblack&quot;&gt;shinyblack&lt;/option&gt;<br />
        &lt;option value=&quot;lightness&quot; selected=&quot;selected&quot;&gt;lightness&lt;/option&gt;<br />
        &lt;option value=&quot;android&quot;&gt;android&lt;/option&gt;<br />
    &lt;/select&gt;<br />
[/html]</p>
<p>The next thing is we need to add the CSS links to the page, here I am going to add some of the CSS references as follows.</p>
<p>[html]<br />
&lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.darkblue.css&quot; rel=&quot;stylesheet&quot; title=&quot;darkblue&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.energyblue.css&quot; rel=&quot;stylesheet&quot; title=&quot;energyblue&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.metro.css&quot; rel=&quot;stylesheet&quot; title=&quot;metro&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.metrodark.css&quot; rel=&quot;stylesheet&quot; title=&quot;metrodark&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.office.css&quot; rel=&quot;stylesheet&quot; title=&quot;office&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-darkness.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-darkness&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-le-frog.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-le-frog&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-lightness.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-lightness.&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-sunny.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-sunny&quot; /&gt;<br />
[/html]</p>
<p>Have you noticed that we are calling the function applyNewCSS in the on change event of the select control. So next thins we will add that function.</p>
<p>[js]<br />
 function applyNewCSS() {<br />
            var css = $.trim($(&quot;#selectOptions&quot;).val());<br />
            if (css == &#8216;metro&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;metro&#8217; });<br />
            }<br />
            else if (css == &#8216;metrodark&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;metrodark&#8217; });<br />
            }<br />
            else if (css == &#8216;office&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;office&#8217; });<br />
            } else if (css == &#8216;orange&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;orange&#8217; });<br />
            } else if (css == &#8216;energyblue&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;energyblue&#8217; });<br />
            } else if (css == &#8216;darkblue&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;darkblue&#8217; });<br />
            } else if (css == &#8216;black&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;black&#8217; });<br />
            } else if (css == &#8216;shinyblack&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;shinyblack&#8217; });<br />
            } else if (css == &#8216;lightness&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;lightness&#8217; });<br />
            } else if (css == &#8216;ui-le-frog&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;ui-le-frog&#8217; });<br />
            } else if (css == &#8216;ui-darkness&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;ui-darkness&#8217; });<br />
            } else if (css == &#8216;ui-sunny&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;ui-sunny&#8217; });<br />
            }<br />
            else if (css == &#8216;android&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;android&#8217; });<br />
            }<br />
        }<br />
[/js]</p>
<blockquote><p>So we can add the theme to the grid as  $(&#8220;#jqxgrid&#8221;).jqxGrid({ theme: &#8216;theme name&#8217; });</p></blockquote>
<p>Here we are applying the theme to the grid according to the user selection. Oops, we forgot one thing. If you apply CSS style sheet directly, the styles won&#8217;t get applied in the page contents. For that we need to disable the remaining style sheets and enable the selected one alone.</p>
<p>Following code will do that magic.</p>
<p>[js]<br />
var i, link_tag;<br />
            for (i = 0, link_tag = document.getElementsByTagName(&quot;link&quot;) ; i &lt; link_tag.length; i++) {<br />
                if ((link_tag[i].rel.indexOf(&quot;stylesheet&quot;) != -1) &amp;&amp; link_tag[i].title) {<br />
                    link_tag[i].disabled = true;<br />
                    if (link_tag[i].title == css) {<br />
                        link_tag[i].disabled = false;<br />
                    }<br />
                }<br />
                set_cookie(&#8216;style&#8217;, css, 30);<br />
            }<br />
[/js]</p>
<p>We are finding all of the link reference and find out whose rel property has the word &#8216;stylesheet&#8217;. Now it is time to see how it woks. </p>
<div id="attachment_10857" style="width: 648px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_1.png"><img decoding="async" aria-describedby="caption-attachment-10857" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_1.png" alt="Change Themes Dynamically In Grid " width="638" height="540" class="size-full wp-image-10857" srcset="/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_1.png 638w, /wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_1-300x254.png 300w, /wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_1-400x339.png 400w" sizes="(max-width: 638px) 100vw, 638px" /></a><p id="caption-attachment-10857" class="wp-caption-text">Change Themes Dynamically In Grid</p></div>
<div id="attachment_10858" style="width: 637px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_2.png"><img decoding="async" aria-describedby="caption-attachment-10858" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_2.png" alt="Change Themes Dynamically In Grid" width="627" height="505" class="size-full wp-image-10858" srcset="/wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_2.png 627w, /wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_2-300x242.png 300w, /wp-content/uploads/2015/10/Change_Themes_Dynamically_In_Grid_2-400x322.png 400w" sizes="(max-width: 627px) 100vw, 627px" /></a><p id="caption-attachment-10858" class="wp-caption-text">Change Themes Dynamically In Grid</p></div>
<p>You can see that the grid themes are changing according to the user selection of theme.That&#8217;s all we have done it. </p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Change Themes Dynamically In Grid &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;</p>
<p>    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.darkblue.css&quot; rel=&quot;stylesheet&quot; title=&quot;darkblue&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.energyblue.css&quot; rel=&quot;stylesheet&quot; title=&quot;energyblue&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.metro.css&quot; rel=&quot;stylesheet&quot; title=&quot;metro&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.metrodark.css&quot; rel=&quot;stylesheet&quot; title=&quot;metrodark&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.office.css&quot; rel=&quot;stylesheet&quot; title=&quot;office&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-darkness.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-darkness&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-le-frog.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-le-frog&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-lightness.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-lightness.&quot; /&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.ui-sunny.css&quot; rel=&quot;stylesheet&quot; title=&quot;ui-sunny&quot; /&gt;</p>
<p>    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        function applyNewCSS() {<br />
            var css = $.trim($(&quot;#selectOptions&quot;).val());<br />
            var i, link_tag;<br />
            for (i = 0, link_tag = document.getElementsByTagName(&quot;link&quot;) ; i &lt; link_tag.length; i++) {<br />
                if ((link_tag[i].rel.indexOf(&quot;stylesheet&quot;) != -1) &amp;&amp; link_tag[i].title) {<br />
                    link_tag[i].disabled = true;<br />
                    if (link_tag[i].title == css) {<br />
                        link_tag[i].disabled = false;<br />
                    }<br />
                }<br />
            }<br />
            if (css == &#8216;metro&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;metro&#8217; });<br />
            }<br />
            else if (css == &#8216;metrodark&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;metrodark&#8217; });<br />
            }<br />
            else if (css == &#8216;office&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;office&#8217; });<br />
            } else if (css == &#8216;orange&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;orange&#8217; });<br />
            } else if (css == &#8216;energyblue&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;energyblue&#8217; });<br />
            } else if (css == &#8216;darkblue&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;darkblue&#8217; });<br />
            } else if (css == &#8216;black&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;black&#8217; });<br />
            } else if (css == &#8216;shinyblack&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;shinyblack&#8217; });<br />
            } else if (css == &#8216;lightness&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;lightness&#8217; });<br />
            } else if (css == &#8216;ui-le-frog&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;ui-le-frog&#8217; });<br />
            } else if (css == &#8216;ui-darkness&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;ui-darkness&#8217; });<br />
            } else if (css == &#8216;ui-sunny&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;ui-sunny&#8217; });<br />
            }<br />
            else if (css == &#8216;android&#8217;) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid({ theme: &#8216;android&#8217; });<br />
            }<br />
        }<br />
        $(document).ready(function () {<br />
            // prepare the data<br />
            var data =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: [{ &quot;name&quot;: &quot;AreaCode&quot;, &quot;type&quot;: &quot;string&quot; }, { &quot;name&quot;: &quot;Revenue&quot;, &quot;type&quot;: &quot;number&quot; }],<br />
                url: &quot;jsonData.txt&quot;<br />
            };<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;Area Code&quot;, &quot;dataField&quot;: &quot;AreaCode&quot;, &quot;cellsalign&quot;: &quot;left&quot;, &quot;cellsformat&quot;: &quot;d&quot; }, { &quot;text&quot;: &quot;Revenue&quot;, &quot;dataField&quot;: &quot;Revenue&quot;, &quot;cellsalign&quot;: &quot;right&quot;, &quot;cellsformat&quot;: &quot;c2&quot; }],<br />
                  });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;h3&gt;Change Themes Dynamically In Grid &#8211; Sibeesh Passion&lt;/h3&gt;<br />
    &lt;br /&gt;<br />
    &lt;div id=&#8217;jqxWidget&#8217; style=&quot;float: left; width: 99.9%;&quot;&gt;<br />
        &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
    &lt;/div&gt;<br />
    &lt;br /&gt;<br />
    &lt;br /&gt;<br />
    &lt;select id=&quot;selectOptions&quot; onchange=&quot;applyNewCSS()&quot;&gt;<br />
        &lt;option value=&quot;0&quot;&gt;Select Template&lt;/option&gt;<br />
        &lt;option value=&quot;metro&quot;&gt;metro&lt;/option&gt;<br />
        &lt;option value=&quot;office&quot;&gt;office&lt;/option&gt;<br />
        &lt;option value=&quot;orange&quot;&gt;orange&lt;/option&gt;<br />
        &lt;option value=&quot;energyblue&quot;&gt;energyblue&lt;/option&gt;<br />
        &lt;option value=&quot;darkblue&quot;&gt;darkblue&lt;/option&gt;<br />
        &lt;option value=&quot;shinyblack&quot;&gt;shinyblack&lt;/option&gt;<br />
        &lt;option value=&quot;lightness&quot; selected=&quot;selected&quot;&gt;lightness&lt;/option&gt;<br />
        &lt;option value=&quot;android&quot;&gt;android&lt;/option&gt;<br />
    &lt;/select&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever wanted to do this requirement? Did you try jQWidget yet? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/change-themes-dynamically-in-grid/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Change Header Names Dynamically In JQwidgets JQX grid</title>
		<link>https://mail.sibeeshpassion.com/change-header-names-dynamically-in-jqwidgets-jqx-grid/</link>
					<comments>https://mail.sibeeshpassion.com/change-header-names-dynamically-in-jqwidgets-jqx-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 28 Oct 2015 11:15:33 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[Change Header Names Dynamically In JQwidgets JQX grid]]></category>
		<category><![CDATA[jQWidget]]></category>
		<category><![CDATA[JQXGrid]]></category>
		<category><![CDATA[setcolumnproperty JQX Grid]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10850</guid>

					<description><![CDATA[In this post we will see how we can Change Header Names Dynamically In JQwidgets JQX grid. I recently came across a situation to change the grid&#8217;s header columns text should be changed dynamically, when ever user change a text box content. So I have done this requirement by using some in-built functionalities of jQWidget JQX grid. Here I am going to share you that. I hope you will like it. To load a grid from a JSON, you can follows the steps as discussed in this article: Load jQWidget JQX Grid From JSON Background If you are new to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can Change Header Names Dynamically In JQwidgets JQX grid. I recently came across a situation to change the grid&#8217;s header columns text should be changed dynamically, when ever user change a text box content. So I have done this requirement by using some in-built functionalities of jQWidget JQX grid. Here I am going to share you that. I hope you will like it.</p>
<p>To load a grid from a JSON, you can follows the steps as discussed in this article: <a href="http://sibeeshpassion.com/bind-json-data-to-jqwidget-jqx-grid/">Load jQWidget JQX Grid From JSON</a></p>
<p><strong>Background</strong></p>
<p>If you are new to JQWidget JQX Grid, Please find out here: <a href="http://sibeeshpassion.com/category/jqwidgets/" target="_blank">http://sibeeshpassion.com/category/jqwidgets/</a></p>
<p><strong>Using the code</strong></p>
<p>I hope you have implemented your grid as shown in that article. Now I guess your page will be looking like this.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Change Header Names Dynamically In JQwidgets JQX grid &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;</p>
<p>    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            // prepare the data<br />
            var data =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: [{ &quot;name&quot;: &quot;AreaCode&quot;, &quot;type&quot;: &quot;string&quot; }, { &quot;name&quot;: &quot;Revenue&quot;, &quot;type&quot;: &quot;number&quot; }],<br />
                //id: &#8216;id&#8217;,<br />
                url: &quot;jsonData.txt&quot;<br />
            };<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;Area Code&quot;, &quot;dataField&quot;: &quot;AreaCode&quot;, &quot;cellsalign&quot;: &quot;left&quot;, &quot;cellsformat&quot;: &quot;d&quot; }, { &quot;text&quot;: &quot;Revenue&quot;, &quot;dataField&quot;: &quot;Revenue&quot;, &quot;cellsalign&quot;: &quot;right&quot;, &quot;cellsformat&quot;: &quot;c2&quot; }],<br />
                      pageable: true,<br />
                      filterable: true,<br />
                      sortable: true<br />
                  });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body class=&#8217;default&#8217;&gt;<br />
    &lt;h2&gt;Change Header Names Dynamically In JQwidgets JQX grid &#8211; Sibeesh Passion&lt;/h2&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p>Now let us make sure that grid is working fine. Please run your project. </p>
<div id="attachment_10851" style="width: 653px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid.png"><img decoding="async" aria-describedby="caption-attachment-10851" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid.png" alt="Change Header Names Dynamically In JQwidgets JQX grid" width="643" height="475" class="size-full wp-image-10851" srcset="/wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid.png 643w, /wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid-300x222.png 300w, /wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid-400x295.png 400w" sizes="(max-width: 643px) 100vw, 643px" /></a><p id="caption-attachment-10851" class="wp-caption-text">Change Header Names Dynamically In JQwidgets JQX grid</p></div>
<p>Cool, so grid is loaded. Now need to add a select control in which we are going to load the grid header names so that user can select which one&#8217;s header must be changed, and a text box where a user can enter the text to be changed for the selected header. Is that fine?</p>
<p>[html]<br />
  &lt;select id=&quot;selectOptions&quot;&gt;&lt;/select&gt;<br />
    &lt;input type=&quot;text&quot; id=&quot;changeName&quot; /&gt;<br />
[/html]</p>
<p>The next thing is we need to add the options to the select control. Right? We can get the column properties of JQX grid as $(&#8220;#jqxgrid&#8221;).jqxGrid(&#8216;columns&#8217;).records. Now we will create a ready function in the grid settings and append the values. Following is the code for that.</p>
<p>[js]<br />
 ready: function () {<br />
                          var options = &quot;&lt;option value=&#8217;0&#8242;&gt;&#8211;Select Header&#8211;&lt;/option&gt;&quot;;<br />
                          var headerNames = $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;columns&#8217;).records;<br />
                          for (var i = 0; i &lt; headerNames.length; i++) {<br />
                              options += &quot;&lt;option value = &#8216;&quot; + headerNames[i].datafield + &quot;&#8217;&gt;&quot; + headerNames[i].text + &quot; &lt;/option&gt;&quot;;<br />
                          }<br />
                          $(&quot;#selectOptions&quot;).html(options);<br />
                      }<br />
[/js]</p>
<p>What is next? Yeah, we need to fire the text box change event. </p>
<p>[js]<br />
$(&quot;#changeName&quot;).change(function (e) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;setcolumnproperty&#8217;, $(&#8216;#selectOptions option:selected&#8217;).val(), &#8216;text&#8217;, $(&#8216;#changeName&#8217;).val());<br />
            });<br />
[/js]</p>
<p>In the text box change event we have written the code to change the header column text property.</p>
<blockquote><p>Here we are using setcolumnproperty method which already available in the JQWidget library.</p></blockquote>
<p>Now it is time to see how it woks. </p>
<div id="attachment_10852" style="width: 654px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid_1.png"><img decoding="async" aria-describedby="caption-attachment-10852" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid_1.png" alt="Change Header Names Dynamically In JQwidgets JQX grid" width="644" height="567" class="size-full wp-image-10852" srcset="/wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid_1.png 644w, /wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid_1-300x264.png 300w, /wp-content/uploads/2015/10/Change_Header_Names_Dynamically_In_JQwidgets_JQX_grid_1-400x352.png 400w" sizes="(max-width: 644px) 100vw, 644px" /></a><p id="caption-attachment-10852" class="wp-caption-text">Change Header Names Dynamically In JQwidgets JQX grid</p></div>
<p>You can see that the header column text has been changed from &#8216;Area Code&#8217; to &#8216;New Area Code&#8217;.That&#8217;s all we have done it. </p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Change Header Names Dynamically In JQwidgets JQX grid &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;</p>
<p>    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            // prepare the data<br />
            var data =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: [{ &quot;name&quot;: &quot;AreaCode&quot;, &quot;type&quot;: &quot;string&quot; }, { &quot;name&quot;: &quot;Revenue&quot;, &quot;type&quot;: &quot;number&quot; }],<br />
                //id: &#8216;id&#8217;,<br />
                url: &quot;jsonData.txt&quot;<br />
            };<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;Area Code&quot;, &quot;dataField&quot;: &quot;AreaCode&quot;, &quot;cellsalign&quot;: &quot;left&quot;, &quot;cellsformat&quot;: &quot;d&quot; }, { &quot;text&quot;: &quot;Revenue&quot;, &quot;dataField&quot;: &quot;Revenue&quot;, &quot;cellsalign&quot;: &quot;right&quot;, &quot;cellsformat&quot;: &quot;c2&quot; }],<br />
                      pageable: true,<br />
                      filterable: true,<br />
                      sortable: true,<br />
                      ready: function () {<br />
                          var options = &quot;&lt;option value=&#8217;0&#8242;&gt;&#8211;Select Header&#8211;&lt;/option&gt;&quot;;<br />
                          var headerNames = $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;columns&#8217;).records;<br />
                          for (var i = 0; i &lt; headerNames.length; i++) {<br />
                              options += &quot;&lt;option value = &#8216;&quot; + headerNames[i].datafield + &quot;&#8217;&gt;&quot; + headerNames[i].text + &quot; &lt;/option&gt;&quot;;<br />
                          }<br />
                          $(&quot;#selectOptions&quot;).html(options);<br />
                      }<br />
                  });<br />
            $(&quot;#changeName&quot;).change(function (e) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;setcolumnproperty&#8217;, $(&#8216;#selectOptions option:selected&#8217;).val(), &#8216;text&#8217;, $(&#8216;#changeName&#8217;).val());<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body class=&#8217;default&#8217;&gt;<br />
    &lt;h3&gt;Change Header Names Dynamically In JQwidgets JQX grid &#8211; Sibeesh Passion&lt;/h3&gt;<br />
    &lt;br /&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
    &lt;br /&gt;<br />
    &lt;br /&gt;<br />
    &lt;select id=&quot;selectOptions&quot;&gt;&lt;/select&gt;<br />
    &lt;input type=&quot;text&quot; id=&quot;changeName&quot; /&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever wanted to do this requirement? Did you try jQWidget yet? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/change-header-names-dynamically-in-jqwidgets-jqx-grid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Order Filter Conditions In jQWidget JQX Grid</title>
		<link>https://mail.sibeeshpassion.com/order-filter-conditions-in-jqwidget-jqx-grid/</link>
					<comments>https://mail.sibeeshpassion.com/order-filter-conditions-in-jqwidget-jqx-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 20 Oct 2015 09:56:57 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[Default Filter Condition in Grid Filter Dropdown]]></category>
		<category><![CDATA[jQWidget]]></category>
		<category><![CDATA[JQX Grid Filter]]></category>
		<category><![CDATA[Order Filter Conditions In jQWidget JQX Grid]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10816</guid>

					<description><![CDATA[In this post we will see how we can set the default filter condition in JQX Grid filter drop down or how we can order jqx grid jqwidget filter conditions. I recently came across a situation that the grid filter condition must be shown as &#8216;equal&#8217; for any type of filter like string, numeric. So I have done this requirement by using some in-built functionalities of jQWidget JQX grid. Here I am going to share you that. I hope you will like it. To load a grid from a JSON, you can follows the steps as discussed in this article: [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can set the default filter condition in JQX Grid filter drop down or how we can order jqx grid jqwidget filter conditions. I recently came across a situation that the grid filter condition must be shown as &#8216;equal&#8217; for any type of filter like string, numeric. So I have done this requirement by using some in-built functionalities of jQWidget JQX grid. Here I am going to share you that. I hope you will like it.</p>
<p>To load a grid from a JSON, you can follows the steps as discussed in this article: <a href="http://sibeeshpassion.com/bind-json-data-to-jqwidget-jqx-grid/">Load jQWidget JQX Grid From JSON</a></p>
<p><strong>Background</strong></p>
<p>If you are new to JQWidget JQX Grid, Please find out here: <a href="http://sibeeshpassion.com/category/jqwidgets/" target="_blank">http://sibeeshpassion.com/category/jqwidgets/</a></p>
<p><strong>Using the code</strong></p>
<p>I hope you have implemented your grid as shown in that article. Now I guess your page will be looking like this.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Order Filter Conditions In JQX Grid &#8211; Sibeesh Passion&lt;/title&gt;<br />
    &lt;script src=&quot;jquery-1.9.1.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxcore.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxbuttons.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxscrollbar.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxlistbox.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdropdownlist.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxmenu.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.filter.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.sort.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.selection.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.pager.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsresize.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.columnsreorder.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxgrid.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdata.export.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script type=&quot;text/javascript&quot; src=&quot;JQXItems/jqwidgets/jqxdatatable.js&quot;&gt;&lt;/script&gt;<br />
    &lt;link href=&quot;JQXItems/jqwidgets/styles/jqx.base.css&quot; rel=&quot;stylesheet&quot; /&gt;</p>
<p>    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            // prepare the data<br />
            var data =<br />
            {<br />
                datatype: &quot;json&quot;,<br />
                datafields: [{ &quot;name&quot;: &quot;AreaCode&quot;, &quot;type&quot;: &quot;string&quot; }, { &quot;name&quot;: &quot;Revenue&quot;, &quot;type&quot;: &quot;number&quot; }],<br />
                //id: &#8216;id&#8217;,<br />
                url: &quot;jsonData.txt&quot;<br />
            };<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;Area Code&quot;, &quot;dataField&quot;: &quot;AreaCode&quot;, &quot;cellsalign&quot;: &quot;left&quot;, &quot;cellsformat&quot;: &quot;d&quot; }, { &quot;text&quot;: &quot;Revenue&quot;, &quot;dataField&quot;: &quot;Revenue&quot;, &quot;cellsalign&quot;: &quot;right&quot;, &quot;cellsformat&quot;: &quot;c2&quot; }],<br />
                      pageable: true,<br />
                      filterable: true,<br />
                      sortable: true<br />
                  });<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body class=&#8217;default&#8217;&gt;<br />
    &lt;h2&gt;Order Filter Conditions In JQX Grid &#8211; Sibeesh Passion&lt;/h2&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p>Now let us make sure that grid is working fine. Please run your project. </p>
<div id="attachment_10817" style="width: 637px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid.png"><img decoding="async" aria-describedby="caption-attachment-10817" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid.png" alt="Order Filter Conditions In jQWidget JQX Grid" width="627" height="485" class="size-full wp-image-10817" srcset="/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid.png 627w, /wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid-300x232.png 300w, /wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid-400x309.png 400w" sizes="(max-width: 627px) 100vw, 627px" /></a><p id="caption-attachment-10817" class="wp-caption-text">Order Filter Conditions In jQWidget JQX Grid</p></div>
<p>Cool, so grid is loaded. Now have you noticed that the filter condition shows by default is &#8216;Contains&#8217; ? Now we are going to change that. You might be thinking what kind of requirement is this. But trust me. If client ask, we must do anything at any cost. </p>
<p>Now we are going to add three functions to the grid settings. </p>
<li>rendered</li>
<li>updatefilterconditions</li>
<li>updatefilterpanel</li>
<p>So our grid settings will be looking as follows. </p>
<p>[js]<br />
 $(&quot;#jqxgrid&quot;).jqxGrid(<br />
                  {<br />
                      source: data,<br />
                      columns: [{ &quot;text&quot;: &quot;Area Code&quot;, &quot;dataField&quot;: &quot;AreaCode&quot;, &quot;cellsalign&quot;: &quot;left&quot;, &quot;cellsformat&quot;: &quot;d&quot; }, { &quot;text&quot;: &quot;Revenue&quot;, &quot;dataField&quot;: &quot;Revenue&quot;, &quot;cellsalign&quot;: &quot;right&quot;, &quot;cellsformat&quot;: &quot;c2&quot; }],<br />
                      pageable: true,<br />
                      filterable: true,<br />
                      sortable: true,<br />
                      rendered: function () {<br />
                          var localizationobj = {};<br />
                          filterstringcomparisonoperators = [&#8216;equal&#8217;, &#8217;empty&#8217;, &#8216;not empty&#8217;, &#8216;contains&#8217;, &#8216;does not contain&#8217;, &#8216;starts with&#8217;, &#8216;ends with&#8217;, &#8216;null&#8217;];<br />
                          filternumericcomparisonoperators = [&#8216;equal&#8217;, &#8216;not equal&#8217;, &#8216;less than&#8217;, &#8216;less than or equal&#8217;, &#8216;greater than&#8217;, &#8216;greater than or equal&#8217;, &#8216;null&#8217;, &#8216;not null&#8217;];<br />
                          filterdatecomparisonoperators = [&#8216;equal&#8217;, &#8216;not equal&#8217;, &#8216;less than&#8217;, &#8216;less than or equal&#8217;, &#8216;greater than&#8217;, &#8216;greater than or equal&#8217;, &#8216;null&#8217;, &#8216;not null&#8217;];<br />
                          filterbooleancomparisonoperators = [&#8216;equal&#8217;, &#8216;not equal&#8217;];</p>
<p>                          localizationobj.filterstringcomparisonoperators = filterstringcomparisonoperators;<br />
                          localizationobj.filternumericcomparisonoperators = filternumericcomparisonoperators;<br />
                          localizationobj.filterdatecomparisonoperators = filterdatecomparisonoperators;<br />
                          localizationobj.filterbooleancomparisonoperators = filterbooleancomparisonoperators;</p>
<p>                          // apply localization.<br />
                          $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;localizestrings&#8217;, localizationobj);<br />
                      },<br />
                      updatefilterconditions: function (type, defaultconditions) {<br />
                          var stringcomparisonoperators = [&#8216;EQUAL&#8217;, &#8216;EMPTY&#8217;, &#8216;NOT_EMPTY&#8217;, &#8216;CONTAINS&#8217;, &#8216;DOES_NOT_CONTAIN&#8217;, &#8216;STARTS_WITH&#8217;, &#8216;ENDS_WITH&#8217;, &#8216;NULL&#8217;];<br />
                          var numericcomparisonoperators = [&#8216;EQUAL&#8217;, &#8216;NOT_EQUAL&#8217;, &#8216;LESS_THAN&#8217;, &#8216;LESS_THAN_OR_EQUAL&#8217;, &#8216;GREATER_THAN&#8217;, &#8216;GREATER_THAN_OR_EQUAL&#8217;, &#8216;NULL&#8217;, &#8216;NOT_NULL&#8217;];<br />
                          var datecomparisonoperators = [&#8216;EQUAL&#8217;, &#8216;NOT_EQUAL&#8217;, &#8216;LESS_THAN&#8217;, &#8216;LESS_THAN_OR_EQUAL&#8217;, &#8216;GREATER_THAN&#8217;, &#8216;GREATER_THAN_OR_EQUAL&#8217;, &#8216;NULL&#8217;, &#8216;NOT_NULL&#8217;];<br />
                          var booleancomparisonoperators = [&#8216;EQUAL&#8217;, &#8216;NOT_EQUAL&#8217;];<br />
                          switch (type) {<br />
                              case &#8216;stringfilter&#8217;:<br />
                                  return stringcomparisonoperators;<br />
                              case &#8216;numericfilter&#8217;:<br />
                                  return numericcomparisonoperators;<br />
                              case &#8216;datefilter&#8217;:<br />
                                  return datecomparisonoperators;<br />
                              case &#8216;booleanfilter&#8217;:<br />
                                  return booleancomparisonoperators;<br />
                          }<br />
                      },<br />
                      updatefilterpanel: function (filtertypedropdown1, filtertypedropdown2, filteroperatordropdown, filterinputfield1, filterinputfield2, filterbutton, clearbutton,<br />
                           columnfilter, filtertype, filterconditions) {<br />
                          var index1 = 0;<br />
                          var index2 = 0;<br />
                          filtertypedropdown1.jqxDropDownList({ autoDropDownHeight: true, selectedIndex: index1 });<br />
                          filtertypedropdown2.jqxDropDownList({ autoDropDownHeight: true, selectedIndex: index2 });<br />
                      }<br />
                  });<br />
        });<br />
[/js]</p>
<p>Here in the <em>updatefilterpanel</em> we are setting the index for the filter drop down. And in <em>updatefilterconditions</em> and <em>rendered</em> functions we are applying the localization according to our requirement. Now save the changes and run your grid again, you can see the filter option &#8216;equal&#8217; will be loaded as default. </p>
<div id="attachment_10818" style="width: 622px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid1.png"><img decoding="async" aria-describedby="caption-attachment-10818" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid1.png" alt="Order Filter Conditions In jQWidget JQX Grid" width="612" height="470" class="size-full wp-image-10818" srcset="/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid1.png 612w, /wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid1-300x230.png 300w, /wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid1-400x307.png 400w" sizes="(max-width: 612px) 100vw, 612px" /></a><p id="caption-attachment-10818" class="wp-caption-text">Order Filter Conditions In jQWidget JQX Grid</p></div>
<div id="attachment_10819" style="width: 631px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid2.png"><img decoding="async" aria-describedby="caption-attachment-10819" src="http://sibeeshpassion.com/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid2.png" alt="Order Filter Conditions In jQWidget JQX Grid" width="621" height="480" class="size-full wp-image-10819" srcset="/wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid2.png 621w, /wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid2-300x232.png 300w, /wp-content/uploads/2015/10/Order_Filter_Conditions_In_jQWidget_JQX_Grid2-400x309.png 400w" sizes="(max-width: 621px) 100vw, 621px" /></a><p id="caption-attachment-10819" class="wp-caption-text">Order Filter Conditions In jQWidget JQX Grid</p></div>
<p>That&#8217;s all we have done this requirement of ordering the jQWidget JQX grid filter conditions. </p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever wanted to do this requirement? Did you try jQWidget yet? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/order-filter-conditions-in-jqwidget-jqx-grid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Assign New Data Source To JQWidgets JQX Grid</title>
		<link>https://mail.sibeeshpassion.com/assign-new-data-source-to-jqwidgets-jqx-grid/</link>
					<comments>https://mail.sibeeshpassion.com/assign-new-data-source-to-jqwidgets-jqx-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Fri, 24 Jul 2015 10:54:48 +0000</pubDate>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[jqx data adapter]]></category>
		<category><![CDATA[JQX Datasource]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=7871</guid>

					<description><![CDATA[In this post, we will see how we can assign a new data source to JQWidgets JQX Grid. I hope you will like it. Using The Code [js] var dataAdapter = new $.jqx.dataAdapter(source); $(&#34;#jqxgrid&#34;).jqxGrid({ source: dataAdapter }); [/js] Here jqxgrid is the ID of the div element in which we bind grid. source is our new data source. Please see other code snippets here: Code-Snippets Kindest Regards Sibeesh Venu]]></description>
										<content:encoded><![CDATA[<p>In this post, we will see how we can assign a new data source to JQWidgets JQX Grid. I hope you will like it.</p>
<p><strong>Using The Code</strong></p>
<p>[js]<br />
      var dataAdapter = new $.jqx.dataAdapter(source);<br />
      $(&quot;#jqxgrid&quot;).jqxGrid({ source: dataAdapter });</p>
<p>[/js]</p>
<p>Here <em>jqxgrid</em> is the ID of the div element in which we bind grid.<br />
<em>source</em> is our new data source.</p>
<p>Please see other code snippets here: <a href="http://sibeeshpassion.com/category/code-snippets/" target="_blank">Code-Snippets</a></p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/assign-new-data-source-to-jqwidgets-jqx-grid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Filter parameters are always null in server side paging in JQWidget JQX Grid. Why?</title>
		<link>https://mail.sibeeshpassion.com/filter-parameters-are-always-null-in-server-side-paging/</link>
					<comments>https://mail.sibeeshpassion.com/filter-parameters-are-always-null-in-server-side-paging/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 29 Jun 2015 10:25:20 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Q&A]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filter parameters]]></category>
		<category><![CDATA[forum]]></category>
		<category><![CDATA[jqx data adapter]]></category>
		<category><![CDATA[jqx extend data]]></category>
		<category><![CDATA[jqx source]]></category>
		<category><![CDATA[server side paging]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=5491</guid>

					<description><![CDATA[Hi All, Hi I am working on JQX JQWidget grid. Now I am facing an issue with that. My Filter parameters are always null in server side paging. My call is getting to the controller, but the filter values are not getting. Following is my implementation of source and data adapter object. [js] var source = { datafields: DataFields, datatype: &#34;json&#34;, url: &#8216;../Widget/GetGridData/&#8217;, sort: function () { $(&#34;#advancedgrid&#34;).jqxGrid(&#8216;updatebounddata&#8217;, &#8216;sort&#8217;); }, filter: function () { $(&#34;#advancedgrid&#34;).jqxGrid(&#8216;updatebounddata&#8217;, &#8216;filter&#8217;); }, beforeprocessing: function (data) { source.totalrecords = varDataCount; } }; var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function (data) { var length = dataAdapter.records.length; [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Hi All,<br />
Hi I am working on JQX JQWidget grid. Now I am facing an issue with that. My Filter parameters are always null in server side paging. My call is getting to the controller, but the filter values are not getting. Following is my implementation of source and data adapter object.</p>
<p>[js]<br />
var source =<br />
                          {<br />
                              datafields: DataFields,<br />
                              datatype: &quot;json&quot;,<br />
                              url: &#8216;../Widget/GetGridData/&#8217;,<br />
                              sort: function () {<br />
                                  $(&quot;#advancedgrid&quot;).jqxGrid(&#8216;updatebounddata&#8217;, &#8216;sort&#8217;);<br />
                              },<br />
                              filter: function () {<br />
                                  $(&quot;#advancedgrid&quot;).jqxGrid(&#8216;updatebounddata&#8217;, &#8216;filter&#8217;);<br />
                              },<br />
                              beforeprocessing: function (data) {<br />
                                  source.totalrecords = varDataCount;<br />
                              }<br />
                          };<br />
            var dataAdapter = new $.jqx.dataAdapter(source, {<br />
                loadComplete: function (data) {<br />
                    var length = dataAdapter.records.length;<br />
                },<br />
                loadError: function (jqXHR, status, error) {<br />
                    var test = status;<br />
                    console.log(test);<br />
                },<br />
                downloadComplete: function (data, status, xhr) {<br />
                    debugger;<br />
                    return jQuery.parseJSON(data);<br />
                },<br />
                formatData: function (data) {<br />
                    $.extend(data, {<br />
                        selectedColumn: selectedColumn,<br />
                        selectedRow: selectedRow,<br />
                        selectedMeasures: selectedMeasures,<br />
                        serverName: serverName,<br />
                        databaseName: databaseName,<br />
                        cubeName: cubeName,<br />
                        queryTemplate: QueryTemplate,<br />
                        chartMode: ChartMode,<br />
                        chartType: chartType<br />
                    });<br />
                    return data;<br />
                }<br />
            });<br />
[/js]</p>
<p>Please help me. Thanks in advance.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/filter-parameters-are-always-null-in-server-side-paging/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Compress XML, String, Variables in Client Side and Export in HTML5 Using jQuery</title>
		<link>https://mail.sibeeshpassion.com/compress-xml-string-variables-in-client-side-and-export-in-html5-using-jquery/</link>
					<comments>https://mail.sibeeshpassion.com/compress-xml-string-variables-in-client-side-and-export-in-html5-using-jquery/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 24 Jun 2015 03:56:24 +0000</pubDate>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Client-side Export]]></category>
		<category><![CDATA[Compression in the client side]]></category>
		<category><![CDATA[Decompression in the client side]]></category>
		<category><![CDATA[Export]]></category>
		<category><![CDATA[Export in jQuery.]]></category>
		<category><![CDATA[Export using BLOB]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=1151</guid>

					<description><![CDATA[In this post, we will see how we can compress xml, string, variables in client side and export in html5. We will use JQuery for exporting this. Normally developers download Excel of any other file format from the server side. It may be the correct way to do the exporting if and only if the data is quite small. As you all know, when you develop a product or website, you may need to convince many people including in that project. You must convince your client because he/she is paying for it. 🙂 Your client will always look at whether [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post, we will see how we can compress xml, string, variables in client side and export in html5. We will use JQuery for exporting this. Normally developers download Excel of any other file format from the server side. It may be the correct way to do the exporting if and only if the data is quite small. As you all know, when you develop a product or website, you may need to convince many people including in that project. You must convince your client because he/she is paying for it. 🙂 Your client will always look at whether your product is worth the money he will spend.</p>
<p><strong>Download Source</strong></p>
<li><a href="http://sibeeshpassion.com/download/SampleExcelFileData.rar" target="_blank">Sample Data</a></li>
<li><a href="http://sibeeshpassion.com/download/CompressionAndExport.rar" target="_blank">CompressExport</a></li>
<p><strong>Background</strong></p>
<p>For the past few months I am working on the client side exporting, compression, decompression and so on.</p>
<p>Before going through the client-side mechanisms, you must be aware of what all the problems are in server-side exporting.</p>
<li>You need to upload the content to the server first. This will take time when the data is more. When it takes more than 2 minutes, no one will wait for it. They will just cancel the process and close your application. So your reputation is diminished.</li>
<li>Once the contents are uploaded, the server will initiate the process of downloading. Again this may take time.</li>
<p><strong>The Process</strong></p>
<p>The process that I will do is so simple.</p>
<p>You may need to look at my previous article that explains the Excel exporting mechanism in the client side.</p>
<p><a href="http://sibeeshpassion.com/Export-HTML-Table-Using-JQuery/">http://sibeeshpassion.com/Export-HTML-Table-Using-JQuery/</a><br />
<a href="http://sibeeshpassion.com/export-hierarchical-multi-level-html-table-with-styles-using-jquery/" target="_blank">http://sibeeshpassion.com/export-hierarchical-multi-level-html-table-with-styles-using-jquery/</a></p>
<p>Here I am listing what exactly I am going to do with my data.</p>
<p>1. Please find the sample excel file data <a href="http://sibeeshpassion.com/download/SampleExcelFileData.rar" target="_blank">here </a>. Consider that I have data as in that document. You can see some content but there is not much. I am giving you a demo with that content. I have taken this data from the JQX Grid. For the past few months I have been working in JQX JQwidgets, the implementation I have done is for using it in my JQX grid. If you are new to JQX Grid you can check the following links.</p>
<p><a href="http://sibeeshpassion.com/category/products/jqwidgets/" target="_blank">http://sibeeshpassion.com/category/products/jqwidgets/</a></p>
<p>2. Once the data is ready we can go with the compression part. We have the XML string as our data. We are going with the client-side compression mechanism.</p>
<p>For the compression I have used LZW compression, please find more <a href="http://rosettacode.org/wiki/LZW_compression#JavaScript" target="_blank">here</a>.</p>
<p>The following is the code for the compression:<br />
[js]<br />
 var LZW = {<br />
    compress: function (uncompressed) {<br />
        “use strict”;<br />
        // Build the dictionary.<br />
        var i,<br />
            dictionary = {},<br />
            c,<br />
            wc,<br />
            w = “”,<br />
            result = [],<br />
            dictSize = 256;<br />
        for (i = 0; i &lt; 256; i += 1) {<br />
            dictionary[String.fromCharCode(i)] = i;<br />
        }<br />
        for (i = 0; i &lt; uncompressed.length; i += 1) {<br />
            c = uncompressed.charAt(i);<br />
            wc = w + c;<br />
            //Do not use dictionary[wc] because javascript arrays<br />
            //will return values for array[‘pop’], array[‘push’] etc<br />
            // if (dictionary[wc]) {<br />
            if (dictionary.hasOwnProperty(wc)) {<br />
                w = wc;<br />
            } else {<br />
                result.push(dictionary[w]);<br />
                // Add wc to the dictionary.<br />
                dictionary[wc] = dictSize++;<br />
                w = String(c);<br />
            }<br />
        }<br />
        if (w !== “”) {<br />
            result.push(dictionary[w]);<br />
        }<br />
        return result;<br />
    }<br />
}<br />
[/js]</p>
<p>The preceding code does the compression, now we need to check the implementation. Am I right?<br />
[js]<br />
$(“#excelExport”).click(function () {<br />
   var exportInfo = LZW.compress($(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’));<br />
});<br />
[/js]</p>
<p>In the preceding code you can see that I am compressing the data that I have taken from the JQX Grid.</p>
<p>You can get the grid data as follows.<br />
[js]<br />
$(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’);<br />
[/js]</p>
<p>To learn more about exporting in JQX Grid, please see here: <a href="http://sibeeshpassion.com/advanced-jqx-grid-with-all-functionality/" target="_blank">Advanced JQX Grid With All Functionality.</a></p>
<p>You can always decompress the data as follows.<br />
[js]<br />
decompressedVariable = LZW.decompress(exportInfo);<br />
[/js]</p>
<p>The following is the code for the decompression:<br />
[js]<br />
decompress: function (compressed) {<br />
    “use strict”;<br />
    // Build the dictionary.<br />
    var i,<br />
        dictionary = [],<br />
        w,<br />
        result,<br />
        k,<br />
        entry = “”,<br />
        dictSize = 256;<br />
    for (i = 0; i &lt; 256; i += 1) {<br />
        dictionary[i] = String.fromCharCode(i);<br />
    }<br />
    w = String.fromCharCode(compressed[0]);<br />
    result = w;<br />
    for (i = 1; i &lt; compressed.length; i += 1) {<br />
        k = compressed[i];<br />
        if (dictionary[k]) {<br />
            entry = dictionary[k];<br />
        } else {<br />
            if (k === dictSize) {<br />
                entry = w + w.charAt(0);<br />
            } else {<br />
                return null;<br />
            }<br />
        }<br />
        result += entry;<br />
        // Add w+entry[0] to the dictionary.<br />
        dictionary[dictSize++] = w + entry.charAt(0);<br />
        w = entry;<br />
    }<br />
    return result;<br />
}<br />
[/js]</p>
<p>Output Compression And Decompression:</p>
<div id="attachment_9581" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export1.jpg"><img decoding="async" aria-describedby="caption-attachment-9581" src="http://sibeeshpassion.com/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export1.jpg" alt="Compress XML, String, Variables in Client Side and Export" width="650" height="212" class="size-full wp-image-9581" srcset="/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export1.jpg 634w, /wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export1-300x98.jpg 300w, /wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export1-400x130.jpg 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-9581" class="wp-caption-text">Compress XML, String, Variables in Client Side and Export</p></div>
<div id="attachment_9591" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export2.jpg"><img decoding="async" aria-describedby="caption-attachment-9591" src="http://sibeeshpassion.com/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export2.jpg" alt="Compress XML, String, Variables in Client Side and Export" width="650" height="310" class="size-full wp-image-9591" srcset="/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export2.jpg 634w, /wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export2-300x143.jpg 300w, /wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export2-400x191.jpg 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-9591" class="wp-caption-text">Compress XML, String, Variables in Client Side and Export</p></div>
<p>In the preceding image you can see the length of the content before compression and after compression.</p>
<p>Before compression, the length is 41447. And after compression the length is 5452.</p>
<p>Now we know how to compress and decompress the contents :).</p>
<p>Cool. We have done it.</p>
<p>What else is pending? Yeah you are right, we need to export that content.</p>
<p><strong>Exporting Using BLOB</strong></p>
<p>Excel exporting is an important feature in every application. Yeah we do have an Excel exporting mechanism. 🙂<br />
For the Excel exporting we are using a new technology called BLOB in HTML5. To work on it, you need to attach the script.</p>
<p>[js]<br />
&lt;script src=“FileSaver.min.js”&gt;&lt;/script&gt;<br />
[/js]</p>
<p>This script does the saving of the Excel file. So it is important that we include it though. So once you have included that file we can move on to the next level.</p>
<p><strong>The Implementation</strong></p>
<p>The following code explains the implementation.<br />
[js]<br />
//This will download the excel file without compression (before compression of data)</p>
<p>saveMyFile($(‘#SubmitForm’), “My Excel File” + “.xls”, $(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’), ‘text/xls;charset=utf-8′);</p>
<p>//this will download the file with compression (after compression of the data)</p>
<p>saveMyFile($(‘#SubmitForm’), “My Excel File” + “.xls”, exportInfo, ‘text/xls;charset=utf-8′);<br />
[/js]</p>
<p>You can see that the parameters of the function saveMyFile,</p>
<li>Reference form.</li>
<li>File name.</li>
<li>The string to be exported. In our case, it is our XML string.</li>
<li>The mime type, for example: ‘text/xls;charset=utf-8′.</li>
<p><strong>The export function</strong><br />
[js]<br />
function saveMyFile(ref, fname, text, mime) {<br />
   var blob = new Blob([text], { type: mime });<br />
   saveAs(blob, fname);<br />
   return false;<br />
}<br />
[/js]</p>
<p>Once you pass the parameters, this function will do the remaining of what needs to be done. Sounds great, right? 🙂<br />
Your Excel file will be exported in a fraction of a second. Great work by the Blob function. 🙂</p>
<p><strong>See the file size difference</strong></p>
<p>Now I hope you have two downloaded files:</p>
<li>Without compression</li>
<li>With compression</li>
<p>Let us see the size difference now.</p>
<div id="attachment_9601" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export3.jpg"><img decoding="async" aria-describedby="caption-attachment-9601" src="http://sibeeshpassion.com/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export3.jpg" alt="Compress XML, String, Variables in Client Side and Export" width="650" height="101" class="size-full wp-image-9601" srcset="/wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export3.jpg 634w, /wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export3-300x47.jpg 300w, /wp-content/uploads/2015/06/Compress-XML-String-Variables-in-Client-Side-and-Export3-400x62.jpg 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-9601" class="wp-caption-text">Compress XML, String, Variables in Client Side and Export</p></div>
<p>Here, My Excel File.xls is without compression and My Excel File(1).xls is with compression. I hope you see the difference. 🙂</p>
<p>Now it is time for the complete Code.</p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=“en”&gt;<br />
&lt;head&gt;<br />
    &lt;title id=‘Description’&gt;This example illustrates how to customize the filtering conditions available in the columns popup menu.<br />
    &lt;/title&gt;<br />
    &lt;script src=“jquery-1.9.1.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxcore.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxdata.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxbuttons.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxscrollbar.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxlistbox.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxdropdownlist.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.filter.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.sort.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.selection.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.pager.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.columnsresize.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.columnsreorder.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxgrid.export.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxdata.export.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“JQXItems/jqwidgets/jqxdatatable.js”&gt;&lt;/script&gt;<br />
    &lt;script src=“JQXItems/jqwidgets/jqxcheckbox.js”&gt;&lt;/script&gt;<br />
    &lt;script src=“JQXItems/jqwidgets/jqxmenu.js”&gt;&lt;/script&gt;<br />
    &lt;link href=“JQXItems/jqwidgets/styles/jqx.base.css” rel=“stylesheet” /&gt;<br />
    &lt;script src=“generatedata.js”&gt;&lt;/script&gt;<br />
    &lt;script src=“FileSaver.min.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript”&gt;<br />
        $(document).ready(function () {<br />
            var LZW = {<br />
                compress: function (uncompressed) {<br />
                    “use strict”;<br />
                    // Build the dictionary.<br />
                    var i,<br />
                        dictionary = {},<br />
                        c,<br />
                        wc,<br />
                        w = “”,<br />
                        result = [],<br />
                        dictSize = 256;<br />
                    for (i = 0; i &lt; 256; i += 1) {<br />
                        dictionary[String.fromCharCode(i)] = i;<br />
                    }<br />
                    for (i = 0; i &lt; uncompressed.length; i += 1) {<br />
                        c = uncompressed.charAt(i);<br />
                        wc = w + c;<br />
                        //Do not use dictionary[wc] because javascript arrays<br />
                        //will return values for array[‘pop’], array[‘push’] etc<br />
                        // if (dictionary[wc]) {<br />
                        if (dictionary.hasOwnProperty(wc)) {<br />
                            w = wc;<br />
                        } else {<br />
                            result.push(dictionary[w]);<br />
                            // Add wc to the dictionary.<br />
                            dictionary[wc] = dictSize++;<br />
                            w = String(c);<br />
                        }<br />
                    }<br />
                    if (w !== “”) {<br />
                        result.push(dictionary[w]);<br />
                    }<br />
                    return result;<br />
                },<br />
                decompress: function (compressed) {<br />
                    “use strict”;<br />
                    // Build the dictionary.<br />
                    var i,<br />
                        dictionary = [],<br />
                        w,<br />
                        result,<br />
                        k,<br />
                        entry = “”,<br />
                        dictSize = 256;<br />
                    for (i = 0; i &lt; 256; i += 1) {<br />
                        dictionary[i] = String.fromCharCode(i);<br />
                    }<br />
                    w = String.fromCharCode(compressed[0]);<br />
                    result = w;<br />
                    for (i = 1; i &lt; compressed.length; i += 1) {<br />
                        k = compressed[i];<br />
                        if (dictionary[k]) {<br />
                            entry = dictionary[k];<br />
                        } else {<br />
                            if (k === dictSize) {<br />
                                entry = w + w.charAt(0);<br />
                            } else {<br />
                                return null;<br />
                            }<br />
                        }<br />
                        result += entry;<br />
                        // Add w+entry[0] to the dictionary.<br />
                        dictionary[dictSize++] = w + entry.charAt(0);<br />
                        w = entry;<br />
                    }<br />
                    return result;<br />
                }<br />
            }<br />
            var url = “products.xml”;<br />
            // prepare the data<br />
            var source =<br />
            {<br />
                datatype: “xml”,<br />
                datafields: [<br />
                    { name: ‘ProductName’, type: ‘string’ },<br />
                    { name: ‘QuantityPerUnit’, type: ‘int’ },<br />
                    { name: ‘UnitPrice’, type: ‘float’ },<br />
                    { name: ‘UnitsInStock’, type: ‘float’ },<br />
                    { name: ‘Discontinued’, type: ‘bool’ }<br />
                ],<br />
                root: “Products”,<br />
                record: “Product”,<br />
                id: ‘ProductID’,<br />
                url: url<br />
            };<br />
            var cellclass = function (row, columnfield, value) {<br />
                if (value &lt; 20) {<br />
                    return ‘red’;<br />
                }<br />
                else if (value &gt;= 20 &amp;&amp; value &lt; 50) {<br />
                    return ‘yellow’;<br />
                }<br />
                else return ‘green’;<br />
            }<br />
            var dataAdapter = new $.jqx.dataAdapter(source, {<br />
                downloadComplete: function (data, status, xhr) { },<br />
                loadComplete: function (data) { },<br />
                loadError: function (xhr, status, error) { }<br />
            });<br />
            // initialize jqxGrid<br />
            $(“#jqxgrid”).jqxGrid(<br />
            {<br />
                width: 850,<br />
                source: dataAdapter,<br />
                pageable: true,<br />
                autoheight: true,<br />
                sortable: true,<br />
                altrows: true,<br />
                enabletooltips: true,<br />
                columns: [<br />
                  { text: ‘Product Name’, datafield: ‘ProductName’, width: 250 },<br />
                  { text: ‘Quantity per Unit’, datafield: ‘QuantityPerUnit’, cellsalign: ‘right’, align: ‘right’, width: 120 },<br />
                  { text: ‘Unit Price’, datafield: ‘UnitPrice’, align: ‘right’, cellsalign: ‘right’, cellsformat: ‘c2′, width: 100 },<br />
                  { text: ‘Units In Stock’, datafield: ‘UnitsInStock’, cellsalign: ‘right’, cellclassname: cellclass, width: 100 },<br />
                  { text: ‘Discontinued’, columntype: ‘checkbox’, datafield: ‘Discontinued’ },<br />
                ]<br />
            });<br />
            $(“#excelExport”).click(function () {<br />
                debugger;<br />
                var decompressedVariable;<br />
                console.log($(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’));<br />
                var exportInfo = LZW.compress($(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’));<br />
                //This will download the excel file without compression (before compression of data)<br />
                saveMyFile($(‘#SubmitForm’), “My Excel File” + “.xls”, $(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’), ‘text/xls;charset=utf-8′);<br />
                //this will download the file with compression (after compression of the data)<br />
                saveMyFile($(‘#SubmitForm’), “My Excel File” + “.xls”, exportInfo, ‘text/xls;charset=utf-8′);<br />
                decompressedVariable = LZW.decompress(exportInfo);<br />
            });<br />
            function saveMyFile(ref, fname, text, mime) {<br />
                var blob = new Blob(, { type: mime });<br />
                saveAs(blob, fname);<br />
                return false;<br />
            }<br />
        });<br />
    &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body class=‘default’&gt;<br />
    &lt;input type=“button” value=“Export to Excel” id=‘excelExport’ /&gt;<br />
    &lt;style&gt;<br />
        .green {<br />
            color: black\9;<br />
            background-color: #b6ff00\9;<br />
        }<br />
        .yellow {<br />
            color: black\9;<br />
            background-color: yellow\9;<br />
        }<br />
        .red {<br />
            color: black\9;<br />
            background-color: #e83636\9;<br />
        }<br />
        .green:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .green:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) {<br />
            color: black;<br />
            background-color: #b6ff00;<br />
        }<br />
        .yellow:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .yellow:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) {<br />
            color: black;<br />
            background-color: yellow;<br />
        }<br />
        .red:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .red:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) {<br />
            color: black;<br />
            background-color: #e83636;<br />
        }<br />
    &lt;/style&gt;<br />
    &lt;div id=‘jqxWidget’ style=“font-size: 13px; font-family: Verdana; float: left;”&gt;<br />
        &lt;div id=“jqxgrid”&gt;<br />
        &lt;/div&gt;<br />
    &lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Note: I have implemented the grid with a color render implementation. You can omit it and implement a simple grid if you work on the JQX Grid. Please note that you can give any string for the compression and decompression. For my convenience I selected the JQX Grid data.</p>
<p><strong>Conclusion</strong></p>
<p>Please download the attachment and try it. Please do not forget to give your valuable suggestions.</p>
<p><strong>Point of interest</strong></p>
<p>Export, Client-side Export, Compression in the client side, Decompression in the client side, Export using BLOB, Export in jQuery. </p>
<p>That is all for the day, will see you in another article.</p>
<p>Kindest Regards,</p>
<p><a href="http://sibeeshpassion.com/" target="_blank">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/compress-xml-string-variables-in-client-side-and-export-in-html5-using-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
