<?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>Grid With Sorting &#8211; Sibeesh Passion</title>
	<atom:link href="https://www.sibeeshpassion.com/tag/grid-with-sorting/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 11 Aug 2015 12:49:10 +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>Grid With Sorting &#8211; Sibeesh Passion</title>
	<link>https://www.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Working With JQX Grid With Filtering And Sorting And Searching</title>
		<link>https://www.sibeeshpassion.com/working-with-jqx-grid-with-filtering-and-sorting/</link>
					<comments>https://www.sibeeshpassion.com/working-with-jqx-grid-with-filtering-and-sorting/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sat, 29 Nov 2014 19:16:00 +0000</pubDate>
				<category><![CDATA[JQWidgets]]></category>
		<category><![CDATA[JQX Grid]]></category>
		<category><![CDATA[Client Side Grid]]></category>
		<category><![CDATA[Create JQX grid]]></category>
		<category><![CDATA[Fastest Client Side Grid]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[Grid Data Source]]></category>
		<category><![CDATA[Grid With Filter]]></category>
		<category><![CDATA[Grid With Searching]]></category>
		<category><![CDATA[Grid With Sorting]]></category>
		<category><![CDATA[Load Grid]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=531</guid>

					<description><![CDATA[Introduction We have all worked with JQ Grid. Today I got a requirement to implement JQWidget JQX Grid in my web application. Here I will explain how to implement JQX Grid in our application. Download the needed files JQX Grid With Filtering And Sorting This article has been selected as Asp.Net Community Article of the Day Tuesday, December 30, 2014 (Working with JQX Grid with Filtering and Sorting and Searching) What you must know jQuery : What is jQuery? JavaScript : JavaScript Tutorial CSS 3 : CSS3 Introduction HTML : HTML(5) Tutorial DOM Manipulations in jQuery : jQuery – DOM [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>We have all worked with JQ Grid. Today I got a requirement to implement JQWidget JQX Grid in my web application. Here I will explain how to implement JQX Grid in our application.</p>
<p><strong>Download the needed files</strong></p>
<p><a href="https://github.com/Sibeesh/JQXGrid" target="_blank">JQX Grid With Filtering And Sorting</a></p>
<p><em>This article has been selected as Asp.Net Community Article of the Day Tuesday, December 30, 2014</em><br />
(Working with JQX Grid with Filtering and Sorting and Searching)</p>
<p><strong>What you must know</strong></p>
<p>jQuery : <a href="http://jquery.com/" target="_blank">What is jQuery?</a><br />
JavaScript : <a href="http://www.w3schools.com/js/" target="_blank">JavaScript Tutorial</a><br />
CSS 3 : <a href="http://www.w3schools.com/css/css3_intro.asp" target="_blank">CSS3 Introduction</a><br />
HTML : <a href="http://www.w3schools.com/html/" target="_blank">HTML(5) Tutorial</a><br />
DOM Manipulations in jQuery : <a href="http://www.tutorialspoint.com/jquery/jquery-dom.htm" target="_blank">jQuery – DOM Manipulation Methods</a></p>
<p><strong>Background</strong></p>
<p>We can implement the JQX Grid in MVC and in our web application. You can find the demo here: <a href="http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/filterconditions.htm" target="_blank">jqxGrid</a>.</p>
<p>You can download the necessary file from <a href="http://www.jqwidgets.com/download/" target="_blank">http://www.jqwidgets.com/download/</a>.</p>
<p><strong>What made me choose JQX Grid</strong></p>
<p>What made me choose JQX Grid? The answer is simple. We have so many client-side grid providers (JQGrid, Telerik, JQX and so on). If you are not aware of those, please have a look at:<a href="http://www.sitepoint.com/10-jquery-grids/" target="_blank">http://www.sitepoint.com/10-jquery-grids/</a></p>
<p>But for my requirements the client needs a toggle panel in which the filtering conditions occur. When I searched, JQX Grid has the best performance. (Some others support the same features, but they were a little slow.)</p>
<p><strong>Using the code</strong></p>
<p>There is a procedure we must follow to implement the JQX in our application.</p>
<p>Step 1</p>
<p>Download all the necessary files.</p>
<p>Step 2</p>
<p>Create a new web application.</p>
<div id="attachment_8871" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting.jpg"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-8871" src="http://sibeeshpassion.com/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting.jpg" alt="Working With JQX Grid With Filtering And Sorting And Searching" width="650" height="766" class="size-full wp-image-8871" srcset="/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting.jpg 303w, /wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting-255x300.jpg 255w, /wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting-400x471.jpg 400w, /wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting-509x600.jpg 509w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-8871" class="wp-caption-text">Working With JQX Grid With Filtering And Sorting And Searching</p></div>
<p>Step 3</p>
<p>Add the selected folders to your application.</p>
<div id="attachment_8881" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting2.jpg"><img decoding="async" aria-describedby="caption-attachment-8881" src="http://sibeeshpassion.com/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting2.jpg" alt="Working With JQX Grid With Filtering And Sorting And Searching" width="650" height="346" class="size-full wp-image-8881" srcset="/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting2.jpg 634w, /wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting2-300x160.jpg 300w, /wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting2-400x213.jpg 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-8881" class="wp-caption-text">Working With JQX Grid With Filtering And Sorting And Searching</p></div>
<p>Step 4</p>
<p>Add a new page.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html lang=“en”&gt;<br />
&lt;head&gt;<br />
&lt;/head&gt;<br />
&lt;body &gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>Step 5</p>
<p>Add the style sheets and necessary JavaScript files.<br />
[html]<br />
&lt;link rel=“stylesheet” href=“jqwidgets/styles/jqx.base.css” type=“text/css” /&gt;<br />
    &lt;script type=“text/javascript” src=“scripts/jquery-1.11.1.min.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxcore.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxdata.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxbuttons.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxscrollbar.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxlistbox.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxdropdownlist.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxmenu.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxgrid.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxgrid.filter.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxgrid.sort.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxgrid.selection.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxpanel.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“jqwidgets/jqxcheckbox.js”&gt;&lt;/script&gt;<br />
    &lt;script type=“text/javascript” src=“scripts/demos.js”&gt;&lt;/script&gt;<br />
[/html]</p>
<p>(Make sure that you add the JavaScript files in order.)</p>
<p>Step 6</p>
<p>Create the DOM elements in which you want to show the JQX Grid.<br />
[html]<br />
&lt;div id=‘jqxWidget’ style=“font-size: 13px; font-family: Verdana; float: left;”&gt;<br />
       &lt;div id=“jqxgrid”&gt;<br />
       &lt;/div&gt;<br />
   &lt;/div&gt;<br />
[/html]</p>
<p>Step 7</p>
<p>Generate some dynamic JSON data so that you can easily generate the JQX Grid. You can get the data from the database and convert it to JSON. If you are unfamiliar with how to convert JSON then you can get it here: <a href="https://www.nuget.org/packages/newtonsoft.json/" target="_blank">Json.NET 6.0.6.</a></p>
<p>If you are not aware of how to add the newtonsoft and use it then please see this video. And please dont forget to rate his video. He has done good a job :).</p>
<p><a href="https://www.youtube.com/watch?v=76blDatESaA" target="_blank">JSON Serialization and DeSerialization</a></p>
<p>Here I am generating data dynamically in a JavaScript file. Please find the generatedata.js file in the bundle of the JQX Grid. Please add this to your script section.<br />
[js]<br />
&lt;script src=“generatedata.js” type=“text/javascript”&gt;&lt;/script&gt;<br />
[/js]</p>
<p>If you go into the <em>generatedata.js</em>, you can see a function generatedata, that is for creating the data (JSON array) dynamically .<br />
[js]<br />
function generatedata(rowscount, hasNullValues) {<br />
    // prepare the data<br />
    var data = new Array();<br />
    if (rowscount == #ff0000) rowscount = 100;<br />
    var firstNames =<br />
    [<br />
        “Andrew”, “Nancy”, “Shelley”, “Regina”, “Yoshi”, “Antoni”, “Mayumi”, “Ian”, “Peter”, “Lars”, “Petra”, “Martin”, “Sven”, “Elio”, “Beate”, “Cheryl”, “Michael”, “Guylene”<br />
    ];<br />
    var lastNames =<br />
    [<br />
        “Fuller”, “Davolio”, “Burke”, “Murphy”, “Nagase”, “Saavedra”, “Ohno”, “Devling”, “Wilson”, “Peterson”, “Winkler”, “Bein”, “Petersen”, “Rossi”, “Vileid”, “Saylor”, “Bjorn”, “Nodier”<br />
    ];<br />
    var productNames =<br />
    [<br />
        “Black Tea”, “Green Tea”, “Caffe Espresso”, “Doubleshot Espresso”, “Caffe Latte”, “White Chocolate Mocha”, “Caramel Latte”, “Caffe Americano”, “Cappuccino”, “Espresso Truffle”, “Espresso con Panna”, “Peppermint Mocha Twist”<br />
    ];<br />
    var priceValues =<br />
    [<br />
         “2.25”, “1.5”, “3.0”, “3.3”, “4.5”, “3.6”, “3.8”, “2.5”, “5.0”, “1.75”, “3.25”, “4.0”<br />
    ];<br />
    for (var i = 0; i &lt; rowscount; i++) {<br />
        var row = {};<br />
        var productindex = Math.floor(Math.random() * productNames.length);<br />
        var price = parseFloat(priceValues[productindex]);<br />
        var quantity = 1 + Math.round(Math.random() * 10);<br />
        row[“id”] = i;<br />
        row[“available”] = productindex % 2 == 0;<br />
        if (hasNullValues == true) {<br />
            if (productindex % 2 != 0) {<br />
                var random = Math.floor(Math.random() * rowscount);<br />
                row[“available”] = i % random == 0 ? null : false;<br />
            }<br />
        }<br />
        row[“firstname”] = firstNames[Math.floor(Math.random() * firstNames.length)];<br />
        row[“lastname”] = lastNames[Math.floor(Math.random() * lastNames.length)];<br />
        row[“name”] = row[“firstname”] + ” “ + row[“lastname”];<br />
        row[“productname”] = productNames[productindex];<br />
        row[“price”] = price;<br />
        row[“quantity”] = quantity;<br />
        row[“total”] = price * quantity;<br />
        var date = new Date();<br />
        date.setFullYear(2014, Math.floor(Math.random() * 12), Math.floor(Math.random() * 27));<br />
        date.setHours(0, 0, 0, 0);<br />
        row[“date”] = date;<br />
        data[i] = row;<br />
    }<br />
    return data;<br />
}<br />
[/js]</p>
<p>Step 8 </p>
<p>Now here is the main part. Add the main code to your script tag in the page. Here we are appending the Grid to the element that has the id jqxgrid.<br />
[js]<br />
&lt;script type=“text/javascript”&gt;<br />
        $(document).ready(function () {<br />
            var data = generatedata(500);<br />
            var source =<br />
            {<br />
                localdata: data,<br />
                datafields:<br />
                [<br />
                    { name: ‘firstname’, type: ‘string’ },<br />
                    { name: ‘lastname’, type: ‘string’ },<br />
                    { name: ‘productname’, type: ‘string’ },<br />
                    { name: ‘date’, type: ‘date’ },<br />
                    { name: ‘quantity’, type: ‘number’ }<br />
                ],<br />
                datatype: “array”<br />
            };<br />
            var addfilter = function () {<br />
                var filtergroup = new $.jqx.filter();<br />
                var filter_or_operator = 1;<br />
                var filtervalue = ‘Beate’;<br />
                var filtercondition = ‘contains’;<br />
                var filter1 = filtergroup.createfilter(‘stringfilter’, filtervalue, filtercondition);<br />
                filtervalue = ‘Andrew’;<br />
                filtercondition = ‘contains’;<br />
                var filter2 = filtergroup.createfilter(‘stringfilter’, filtervalue, filtercondition);<br />
                filtergroup.addfilter(filter_or_operator, filter1);<br />
                filtergroup.addfilter(filter_or_operator, filter2);<br />
                // add the filters.<br />
                $(“#jqxgrid”).jqxGrid(‘addfilter’, ‘firstname’, filtergroup);<br />
                // apply the filters.<br />
                $(“#jqxgrid”).jqxGrid(‘applyfilters’);<br />
            }<br />
            var dataAdapter = new $.jqx.dataAdapter(source);<br />
            $(“#jqxgrid”).jqxGrid(<br />
            {<br />
                width: 850,<br />
                source: dataAdapter,<br />
                filterable: true,<br />
                sortable: true,<br />
                autoshowfiltericon: true,<br />
                ready: function () {<br />
                    addfilter();<br />
                    var localizationObject = {<br />
                        filterstringcomparisonoperators: [‘contains’, ‘does not contain’],<br />
                        // filter numeric comparison operators.<br />
                        filternumericcomparisonoperators: [‘less than’, ‘greater than’],<br />
                        // filter date comparison operators.<br />
                        filterdatecomparisonoperators: [‘less than’, ‘greater than’],<br />
                        // filter bool comparison operators.<br />
                        filterbooleancomparisonoperators: [‘equal’, ‘not equal’]<br />
                    }<br />
                    $(“#jqxgrid”).jqxGrid(‘localizestrings’, localizationObject);<br />
                },<br />
                updatefilterconditions: function (type, defaultconditions) {<br />
                    var stringcomparisonoperators = [‘CONTAINS’, ‘DOES_NOT_CONTAIN’];<br />
                    var numericcomparisonoperators = [‘LESS_THAN’, ‘GREATER_THAN’];<br />
                    var datecomparisonoperators = [‘LESS_THAN’, ‘GREATER_THAN’];<br />
                    var booleancomparisonoperators = [‘EQUAL’, ‘NOT_EQUAL’];<br />
                    switch (type) {<br />
                        case ‘stringfilter’:<br />
                            return stringcomparisonoperators;<br />
                        case ‘numericfilter’:<br />
                            return numericcomparisonoperators;<br />
                        case ‘datefilter’:<br />
                            return datecomparisonoperators;<br />
                        case ‘booleanfilter’:<br />
                            return booleancomparisonoperators;<br />
                    }<br />
                },<br />
                updatefilterpanel: function (filtertypedropdown1, filtertypedropdown2, filteroperatordropdown, filterinputfield1, filterinputfield2, filterbutton, clearbutton,<br />
                 columnfilter, filtertype, filterconditions) {<br />
                    var index1 = 0;<br />
                    var index2 = 0;<br />
                    if (columnfilter != null) {<br />
                        var filter1 = columnfilter.getfilterat(0);<br />
                        var filter2 = columnfilter.getfilterat(1);<br />
                        if (filter1) {<br />
                            index1 = filterconditions.indexOf(filter1.comparisonoperator);<br />
                            var value1 = filter1.filtervalue;<br />
                            filterinputfield1.val(value1);<br />
                        }<br />
                        if (filter2) {<br />
                            index2 = filterconditions.indexOf(filter2.comparisonoperator);<br />
                            var value2 = filter2.filtervalue;<br />
                            filterinputfield2.val(value2);<br />
                        }<br />
                    }<br />
                    filtertypedropdown1.jqxDropDownList({ autoDropDownHeight: true, selectedIndex: index1 });<br />
                    filtertypedropdown2.jqxDropDownList({ autoDropDownHeight: true, selectedIndex: index2 });<br />
                },<br />
                columns: [<br />
                  { text: ‘First Name’, datafield: ‘firstname’, width: 200 },<br />
                  { text: ‘Last Name’, datafield: ‘lastname’, width: 200 },<br />
                  { text: ‘Product’, datafield: ‘productname’, width: 180 },<br />
                  { text: ‘Order Date’, datafield: ‘date’, width: 160, cellsformat: ‘dd-MMMM-yyyy’ },<br />
                  { text: ‘Quantity’, datafield: ‘quantity’, cellsalign: ‘right’ }<br />
                ]<br />
            });<br />
            $(‘#events’).jqxPanel({ width: 300, height: 80});<br />
            $(“#jqxgrid”).on(“filter”, function (event) {<br />
                $(“#events”).jqxPanel(‘clearcontent’);<br />
                var filterinfo = $(“#jqxgrid”).jqxGrid(‘getfilterinformation’);<br />
                var eventData = “Triggered ‘filter’ event”;<br />
                for (i = 0; i &lt; filterinfo.length; i++) {<br />
                    var eventData = “Filter Column: “ + filterinfo[i].filtercolumntext;<br />
                    $(‘#events’).jqxPanel(‘prepend’, ‘&lt;div style=”margin-top: 5px;”&gt;’ + eventData + ‘&lt;/div&gt;’);<br />
                }<br />
            });<br />
            $(‘#clearfilteringbutton’).jqxButton({ theme: theme });<br />
            $(‘#filterbackground’).jqxCheckBox({ checked: true, height: 25});<br />
            $(‘#filtericons’).jqxCheckBox({ checked: false, height: 25});<br />
            // clear the filtering.<br />
            $(‘#clearfilteringbutton’).click(function () {<br />
                $(“#jqxgrid”).jqxGrid(‘clearfilters’);<br />
            });<br />
            // show/hide filter background<br />
            $(‘#filterbackground’).on(‘change’, function (event) {<br />
                $(“#jqxgrid”).jqxGrid({ showfiltercolumnbackground: event.args.checked });<br />
            });<br />
            // show/hide filter icons<br />
            $(‘#filtericons’).on(‘change’, function (event) {<br />
                $(“#jqxgrid”).jqxGrid({ autoshowfiltericon: !event.args.checked });<br />
            });<br />
        });<br />
    &lt;/script&gt;<br />
[/js]</p>
<p>Step 9: Now build and run your code, you will get output as in the following:</p>
<div id="attachment_8891" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting3.jpg"><img decoding="async" aria-describedby="caption-attachment-8891" src="http://sibeeshpassion.com/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting3.jpg" alt="Working With JQX Grid With Filtering And Sorting And Searching" width="650" height="314" class="size-full wp-image-8891" srcset="/wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting3.jpg 634w, /wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting3-300x145.jpg 300w, /wp-content/uploads/2014/11/working-with-jqx-grid-with-filtering-and-sorting3-400x193.jpg 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-8891" class="wp-caption-text">Working With JQX Grid With Filtering And Sorting And Searching</p></div>
<p>Have a happy coding 🙂</p>
<p><strong>History</strong></p>
<p>First version on: 13-Oct-2014 10:30 PM.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/working-with-jqx-grid-with-filtering-and-sorting/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
