<?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>JQX Grid &#8211; Sibeesh Passion</title>
	<atom:link href="https://www.sibeeshpassion.com/tag/jqx-grid/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 11 Jul 2018 16:22:30 +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>JQX Grid &#8211; Sibeesh Passion</title>
	<link>https://www.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Implement radio button selection in JQWidgets JQXGrid using checkbox</title>
		<link>https://www.sibeeshpassion.com/implement-radio-button-selection-in-jqwidgets-jqxgrid-using-checkbox/</link>
					<comments>https://www.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://www.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://www.sibeeshpassion.com/dynamically-apply-colour-coding-in-grid-with-dynamic-headers-and-data/</link>
					<comments>https://www.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://www.sibeeshpassion.com/dynamically-apply-colour-coding-in-grid-with-dynamic-headers-and-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Load Data To Grid On Sroll</title>
		<link>https://www.sibeeshpassion.com/load-data-to-grid-on-sroll/</link>
					<comments>https://www.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://www.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://www.sibeeshpassion.com/change-themes-dynamically-in-grid/</link>
					<comments>https://www.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://www.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://www.sibeeshpassion.com/change-header-names-dynamically-in-jqwidgets-jqx-grid/</link>
					<comments>https://www.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://www.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://www.sibeeshpassion.com/order-filter-conditions-in-jqwidget-jqx-grid/</link>
					<comments>https://www.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://www.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://www.sibeeshpassion.com/assign-new-data-source-to-jqwidgets-jqx-grid/</link>
					<comments>https://www.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://www.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://www.sibeeshpassion.com/filter-parameters-are-always-null-in-server-side-paging/</link>
					<comments>https://www.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://www.sibeeshpassion.com/filter-parameters-are-always-null-in-server-side-paging/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Get jqwidget jqx grid column count</title>
		<link>https://www.sibeeshpassion.com/get-jqwidget-jqx-grid-column-count/</link>
					<comments>https://www.sibeeshpassion.com/get-jqwidget-jqx-grid-column-count/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Fri, 19 Jun 2015 07:05:11 +0000</pubDate>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[Column Count JQX Grid]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=5161</guid>

					<description><![CDATA[This code snippet shows how you can get jqwidget jqx grid column count. [js] var count = $(&#34;#jqxgrid&#34;).jqxGrid(&#8216;columns&#8217;).records.length; [/js] Kindest Regards Sibeesh Venu]]></description>
										<content:encoded><![CDATA[<p>This code snippet shows how you can get jqwidget jqx grid column count.<br />
[js]<br />
 var count = $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;columns&#8217;).records.length;<br />
[/js]</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/get-jqwidget-jqx-grid-column-count/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Show/Hide Columns in JQWidgets JQX Grid</title>
		<link>https://www.sibeeshpassion.com/showhide-columns-in-jqwidgets-jqx-grid/</link>
					<comments>https://www.sibeeshpassion.com/showhide-columns-in-jqwidgets-jqx-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Fri, 19 Jun 2015 06:01:02 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Hide Column]]></category>
		<category><![CDATA[JQXGrid Ready]]></category>
		<category><![CDATA[JQXListBox]]></category>
		<category><![CDATA[JQXListBox DataSource]]></category>
		<category><![CDATA[SHow Column]]></category>
		<category><![CDATA[ShowHide Column JQWidget]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=5141</guid>

					<description><![CDATA[Introduction Hi All, How are you today? Today we will learn how we can Show/Hide Columns in JQWidgets JQX Grid. I hope you will like it. Downloads Download the source files here: SHowHideColumnInGrid.rar Background If you are new to JQWidget JQX Grid, Please find out here: http://sibeeshpassion.com/category/jqwidgets/ Using the code Here I am using Visual Studio 2012. We will have a txt file in which we will have the JSON data, you can use this file or you can manually load Json data from server side. So let us start First of all we must include the needed files for [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Hi All, How are you today? Today we will learn how we can Show/Hide Columns in JQWidgets JQX Grid. I hope you will like it.</p>
<p><strong>Downloads</strong></p>
<p>Download the source files here: <a href="http://sibeeshpassion.com/download/SHowHideColumnInGrid.rar" target="_blank">SHowHideColumnInGrid.rar</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>Here I am using Visual Studio 2012. We will have a txt file in which we will have the JSON data, you can use this file or you can manually load Json data from server side.</p>
<p><strong>So let us start</strong></p>
<p>First of all we must include the needed files for the grid.</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>No we can start the grid implementation. For that create a ready function and add the codes as follows.<br />
[js]</p>
<p> &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
           var source =<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 />
        var dataAdapter = new $.jqx.dataAdapter(source);<br />
        $(&quot;#jqxgrid&quot;).jqxGrid(<br />
        {<br />
            width: 600,<br />
            source: dataAdapter,<br />
            ready: function () {<br />
                // callback function which is called by jqxGrid when the widget is initialized and the binding is completed.<br />
                $(&#8216;#readymessage&#8217;).show();<br />
            },<br />
            columnsresize: true,<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;, hidden:true }, { &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;</p>
<p>[/js]</p>
<p>Now if you note, you can find out I have give <em> hidden:true </em> for the grid column implementation. So we have made that column as hidden.</p>
<p>[js]<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;, hidden:true }, { &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 />
[/js]</p>
<p>Now what else we need? Yes, we need to create a div where we can render our grid.</p>
<p>[html]<br />
&lt;body class=&#8217;default&#8217;&gt;<br />
    &lt;div id=&#8217;jqxWidget&#8217;&gt;<br />
        &lt;div id=&quot;readymessage&quot; style=&quot;display:none;padding:25px;&quot;&gt;Show/Hide Columns in JQWidgets JQX Grid @Sibeesh Passion!. Enjoy Coding!.&lt;/div&gt;<br />
        &lt;div style=&quot;float: left;&quot; id=&quot;jqxlistbox&quot;&gt;&lt;/div&gt;<br />
        &lt;div style=&quot;margin-left: 20px; float: left;&quot; id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
    &lt;/div&gt;<br />
&lt;/body&gt;<br />
[/html]</p>
<p>Here I am creating a new dive which is not using for grid rendering. </p>
<p>[html]<br />
&lt;div id=&quot;readymessage&quot; style=&quot;display:none;padding:25px;&quot;&gt;Show/Hide Columns in JQWidgets JQX Grid @Sibeesh Passion!. Enjoy Coding!.&lt;/div&gt;<br />
[/html]</p>
<p>I am going to introduce a function called <em>ready</em> here, What this function does is, it will be fired once the grid is loaded fully. So we can use this function for the operations which must be executed after the grid rendering.</p>
<p>[js]<br />
 ready: function () {<br />
                // callback function which is called by jqxGrid when the widget is initialized and the binding is completed.<br />
                $(&#8216;#readymessage&#8217;).show();<br />
            },<br />
[/js]</p>
<p>Got it?</p>
<p>What about our data? We have not seen our data right? </p>
<p>[js]<br />
[{&quot;AreaCode&quot;:&quot;B697-31&quot;,&quot;Revenue&quot;:12747128.190000001},{&quot;AreaCode&quot;:&quot;B697-92&quot;,&quot;Revenue&quot;:7922559.1600000048},{&quot;AreaCode&quot;:&quot;B697-76&quot;,&quot;Revenue&quot;:7541039.540000001},{&quot;AreaCode&quot;:&quot;B697-46&quot;,&quot;Revenue&quot;:7076495.5800000066},{&quot;AreaCode&quot;:&quot;B553-131&quot;,&quot;Revenue&quot;:5738816.5099999979},{&quot;AreaCode&quot;:&quot;B553-193&quot;,&quot;Revenue&quot;:4608556.52},{&quot;AreaCode&quot;:&quot;B697-74&quot;,&quot;Revenue&quot;:3895194.1099999994},{&quot;AreaCode&quot;:&quot;D158-233&quot;,&quot;Revenue&quot;:3572808.989999996},{&quot;AreaCode&quot;:&quot;B697-78&quot;,&quot;Revenue&quot;:3512657.6999999937},{&quot;AreaCode&quot;:&quot;B672-31&quot;,&quot;Revenue&quot;:2955916.9800000032},{&quot;AreaCode&quot;:&quot;B553-46&quot;,&quot;Revenue&quot;:2806813.7100000042}]<br />
[/js]</p>
<p>All set now. So shall we see the grid now?</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/showhide1.PNG" alt="" /></p>
<p>Now we will create a list box and when a user clicks on the column name , it will be shown/hide. Sounds OK?</p>
<p><strong>List Box Implementation</strong></p>
<p>To load the list box we need a data right?</p>
<p>[js]<br />
var listSource = [{ label: &#8216;Area Code&#8217;, value: &#8216;AreaCode&#8217;, checked: false }, { label: &#8216;Revenue&#8217;, value: &#8216;Revenue&#8217;, checked: true }];<br />
[/js]</p>
<p>No we need to bind this data to list box!.</p>
<p>[js]<br />
 $(&quot;#jqxlistbox&quot;).jqxListBox({ source: listSource, width: 200, height: 200, checkboxes: true });<br />
[/js]</p>
<p>Run the application and see the output, if everything goes fine, you will see the output as follows.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/showhide2.PNG" alt="" /></p>
<p>What next ? We are going to create a <em>checkChange</em> event of our list box now.</p>
<p>[js]<br />
 $(&quot;#jqxlistbox&quot;).on(&#8216;checkChange&#8217;, function (event) {<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;beginupdate&#8217;);<br />
            if (event.args.checked) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;showcolumn&#8217;, event.args.value);<br />
                //alert(event.args.value);<br />
            }<br />
            else {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;hidecolumn&#8217;, event.args.value);<br />
            }<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;endupdate&#8217;);<br />
        });<br />
[/js]</p>
<p>So once user clicks, that particular column will be in hidden or show mode 🙂 . And we are passing the <em>value</em> from the list box which is same as the <em>dataField</em> property of the grid, to the grid 🙂</p>
<p>No we will see our 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;Show/Hide Columns in JQWidgets JQX Grid @Sibeesh Passion!. Enjoy Coding!.&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;<br />
    &lt;script type=&quot;text/javascript&quot;&gt;<br />
        $(document).ready(function () {<br />
            // prepare the data<br />
            var source =<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 />
            var dataAdapter = new $.jqx.dataAdapter(source);<br />
            $(&quot;#jqxgrid&quot;).jqxGrid(<br />
            {<br />
                width: 600,<br />
                source: dataAdapter,<br />
                ready: function () {<br />
                    // callback function which is called by jqxGrid when the widget is initialized and the binding is completed.<br />
                    $(&#8216;#readymessage&#8217;).show();<br />
                },<br />
                columnsresize: true,<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;, hidden: true }, { &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 />
            var listSource = [{ label: &#8216;Area Code&#8217;, value: &#8216;AreaCode&#8217;, checked: false }, { label: &#8216;Revenue&#8217;, value: &#8216;Revenue&#8217;, checked: true }];<br />
            $(&quot;#jqxlistbox&quot;).jqxListBox({ source: listSource, width: 200, height: 200, checkboxes: true });<br />
            $(&quot;#jqxlistbox&quot;).on(&#8216;checkChange&#8217;, function (event) {<br />
                $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;beginupdate&#8217;);<br />
                if (event.args.checked) {<br />
                    $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;showcolumn&#8217;, event.args.value);<br />
                    //alert(event.args.value);<br />
                }<br />
                else {<br />
                    $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;hidecolumn&#8217;, event.args.value);<br />
                }<br />
                $(&quot;#jqxgrid&quot;).jqxGrid(&#8216;endupdate&#8217;);<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;&gt;<br />
        &lt;div id=&quot;readymessage&quot; style=&quot;display: none; padding: 25px;&quot;&gt;Show/Hide Columns in JQWidgets JQX Grid @Sibeesh Passion!. Enjoy Coding!.&lt;/div&gt;<br />
        &lt;div style=&quot;float: left;&quot; id=&quot;jqxlistbox&quot;&gt;&lt;/div&gt;<br />
        &lt;div style=&quot;margin-left: 20px; float: left;&quot; 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><strong>Output</strong></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/showhide.gif" alt="" /></p>
<p><strong>Things to remember</strong></p>
<p>Make sure that your  data type is json in source object.</p>
<p>[js]<br />
datatype: &quot;json&quot;<br />
[/js]</p>
<p>Make sure your json is valid</p>
<p><strong>Conclusion</strong></p>
<p>I hope you will like this article. Please share me your valuable thoughts and comments. Your feedback is always welcomed.</p>
<p>Thanks in advance. Happy coding!</p>
<p>Kindest Regards<br />
<a href="https://plus.google.com/+sibeeshkv" target="_blank">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/showhide-columns-in-jqwidgets-jqx-grid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
