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

<channel>
	<title>JQWidgets &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/jqwidgets/feed/" rel="self" type="application/rss+xml" />
	<link>https://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>JQWidgets &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Implement radio button selection in JQWidgets JQXGrid using checkbox</title>
		<link>https://sibeeshpassion.com/implement-radio-button-selection-in-jqwidgets-jqxgrid-using-checkbox/</link>
					<comments>https://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://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://sibeeshpassion.com/dynamically-apply-colour-coding-in-grid-with-dynamic-headers-and-data/</link>
					<comments>https://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://sibeeshpassion.com/dynamically-apply-colour-coding-in-grid-with-dynamic-headers-and-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>a href Columns In Grid</title>
		<link>https://sibeeshpassion.com/a-href-columns-in-grid/</link>
					<comments>https://sibeeshpassion.com/a-href-columns-in-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Wed, 11 Nov 2015 14:18:54 +0000</pubDate>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[a href Columns In Grid]]></category>
		<category><![CDATA[cellsrenderer]]></category>
		<category><![CDATA[JQXGrid]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=10959</guid>

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

					<description><![CDATA[Introduction Hi All, How are you today? Today we will learn how we can bind a Json data to JQWidget, JQX Grid. I hope you will like it. Downloads Download the source files here: BindJSONToGrid.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 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Hi All, How are you today? Today we will learn how we can bind a Json data to JQWidget, 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/BindJSONToGrid.rar" target="_blank">BindJSONToGrid.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 />
            // 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;</p>
<p>[/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;h2&gt;Bind Json Data to JQwidgets JQX grid &#8211; Sibeesh Passion&lt;/h2&gt;<br />
    &lt;div id=&quot;jqxgrid&quot;&gt;&lt;/div&gt;<br />
[/html]</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><strong>Output</strong></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/bndjsn1.PNG" 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://sibeeshpassion.com/bind-json-data-to-jqwidget-jqx-grid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to disable enter key in JQWidget JQX editable grid</title>
		<link>https://sibeeshpassion.com/how-to-disable-enter-key-in-jqwidget-jqx-editable-grid/</link>
					<comments>https://sibeeshpassion.com/how-to-disable-enter-key-in-jqwidget-jqx-editable-grid/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Fri, 05 Jun 2015 07:41:42 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Disable Enter Key]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=4531</guid>

					<description><![CDATA[Introduction Hi All, I hope you are fine. In this article you will learn how we can disable enter key in JQWidget JQX editable grid. I hope you will like it. Background Morning I was working in a grid control which editable, and I selected a row to edit and started editing. I found some issues when I just pressed enter key. So for the time being I thought of disabling enter key while editing. So I thought of sharing those informations with you. If you are new to JQWidget JQX Grid, please read here: http://sibeeshpassion.com/category/jqwidgets/ Using the code I [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Hi All, I hope you are fine. In this article you will learn how we can disable enter key in JQWidget JQX editable grid. I hope you will like it.</p>
<p><strong>Background</strong></p>
<p>Morning I was working in a grid control which editable, and I selected a row to edit and started editing. I found some issues when I just pressed enter key. So for the time being I thought of disabling enter key while editing. So I thought of sharing those informations with you.</p>
<p>If you are new to JQWidget JQX Grid, please read here: <a href="http://sibeeshpassion.com/category/jqwidgets/">http://sibeeshpassion.com/category/jqwidgets/</a></p>
<p><strong>Using the code</strong></p>
<p>I hope you know the basics of JQWidget JQX grid. So normally we can create a grid as follows.<br />
[js]<br />
 $(&quot;#jqxgrid&quot;).jqxGrid(<br />
            {<br />
                width: &#8216;800px&#8217;,<br />
                source: dataAdapter,<br />
                filterable: true,<br />
                sortable: true,<br />
                pageable: true,<br />
                autorowheight: true,<br />
                altrows: true,<br />
                columnsresize: true,<br />
                columnsreorder: true,<br />
                pagesize: 50,<br />
                pagesizeoptions: [&#8216;5&#8242;, &#8217;10&#8217;, &#8217;15&#8217;, &#8217;20&#8217;, &#8217;30&#8217;, &#8217;40&#8217;, &#8217;50&#8217;],<br />
                filtermode: &#8216;excel&#8217;,<br />
                columns: [<br />
                  { text: &#8216;Supplier Name&#8217;, cellsalign: &#8216;center&#8217;, align: &#8216;left&#8217;, datafield: &#8216;SupplierName&#8217;, width: 110 ,&quot;pinned&quot;:true},<br />
                  { text: &#8216;Name&#8217;,  cellsalign: &#8216;center&#8217;, align: &#8216;center&#8217;, datafield: &#8216;ProductName&#8217;, width: 120 },<br />
                ]<br />
            });<br />
[/js]</p>
<p>To make this enter key disable you need to include the following settings to the grid.</p>
<p>[js]<br />
handlekeyboardnavigation: function (event) {<br />
                        var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;<br />
                        if (key == 13) {<br />
                            return true;<br />
                        }<br />
                    },<br />
[/js]</p>
<p>cool, so now our grid implementation will look like this.</p>
<p>[js]<br />
 $(&quot;#jqxgrid&quot;).jqxGrid(<br />
            {<br />
                width: &#8216;800px&#8217;,<br />
                source: dataAdapter,<br />
handlekeyboardnavigation: function (event) {<br />
                        var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;<br />
                        if (key == 13) {<br />
                            return true;<br />
                        }<br />
                    },<br />
                filterable: true,<br />
                sortable: true,<br />
                pageable: true,<br />
                autorowheight: true,<br />
                altrows: true,<br />
                columnsresize: true,<br />
                columnsreorder: true,<br />
                pagesize: 50,<br />
                pagesizeoptions: [&#8216;5&#8242;, &#8217;10&#8217;, &#8217;15&#8217;, &#8217;20&#8217;, &#8217;30&#8217;, &#8217;40&#8217;, &#8217;50&#8217;],<br />
                filtermode: &#8216;excel&#8217;,<br />
                columns: [<br />
                  { text: &#8216;Supplier Name&#8217;, cellsalign: &#8216;center&#8217;, align: &#8216;left&#8217;, datafield: &#8216;SupplierName&#8217;, width: 110 ,&quot;pinned&quot;:true},<br />
                  { text: &#8216;Name&#8217;,  cellsalign: &#8216;center&#8217;, align: &#8216;center&#8217;, datafield: &#8216;ProductName&#8217;, width: 120 },<br />
                ]<br />
            });<br />
[/js]</p>
<p><strong>Conclusion </strong></p>
<p>I hope you enjoyed reading and found this useful. Please share me your valuable feedback. For me it matters a lot.<br />
Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/how-to-disable-enter-key-in-jqwidget-jqx-editable-grid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
