<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Using jqGrid with ASP.NET MVC: Search and Formatting</title>
	<atom:link href="http://blogs.teamb.com/craigstuntz/2009/04/27/38243/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/</link>
	<description>C# • Entity Framework • Functional Programming • MVC • Web</description>
	<pubDate>Sun, 12 Feb 2012 04:48:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Vikas</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-30087</link>
		<dc:creator>Vikas</dc:creator>
		<pubDate>Wed, 08 Jun 2011 13:40:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-30087</guid>
		<description>Here is the javascript function for add , edit search ,and delete
&lt;code&gt;
GridDemo.Home.GridDemo = {

    setupGrid: function (grid, pager, search) {
        grid.jqGrid({
            datatype: 'json',
            mtype: 'GET',
            viewrecords: true,
            colNames: ['Id','first_name', 'Last Name','age','dob','Address', 'State','sex' ,'Country', 'Subject'],
            colModel: [
                        { name: 'Id', index: 'Id', width: 75, editable: false, editoptions: { readonly: true, size: 10} },
                        { name: 'first_name', index: 'first_name', width: 100, editable: true, editoptions: { size: 10}, editrules: { required: true}},
                        { name: 'last_name', index: 'last_name', width: 100, editable: true, editoptions: { size: 10 }, editrules: { required: true} },
                        { name: 'age', index: 'age', width: 70, editable: true, editoptions: { size: 10 }, editrules: { required: true} },
                        { name: new Date('dob'), index: new Date('dob'), width: 100, editable: true, editoptions: { size: 10 }, editrules: { required: true} },
                        { name: 'address', index: 'address', width: 100, editable: true, editoptions: { size: 10}, editrules: { required: true}},
                        { name: 'state', index: 'state', width: 70, editable: true, editoptions: { size: 10 }, editrules: { required: true} },
                         { name: 'sex', index: 'sex', width: 70, editable: true, editoptions: { size: 10 }, editrules: { required: true} },
                        { name: 'country', index: 'country', width: 70, editable: true, editoptions: { size: 10}, editrules: { required: true}},
                        { name: 'subject', index: 'subject', width: 70, editable: true, editoptions: { size: 10}, editrules: { required: true}}
                      ],
            pager: pager,
            sortname: 'first_name',
            rowNum: 10,
            rowList: [10, 20, 50],
            sortorder: "asc",
            url: "GridStudentDate"
        }).navGrid(pager, { edit: true, add: true, del: true, search: false }, { url: "Create" }, { url: "Create" }, { url: "Delete" });
        
        search.filterGrid("#" + grid.attr("id"), {
            gridModel: false,
            filterModel: [{
                label: 'Search',
                name: 'search',
                stype: 'text'
            }]
        });
    }
};
&lt;/code&gt;
=======================
Now these are the Server Side Method to call these function --
&lt;code&gt;
public ActionResult GridStudentDate(int page, int rows, string search, string sidx, string sord)
        {
            sidx = "first_name";
            StudentDBEntities DB = new StudentDBEntities();
            var student = from r in DB.studentDetails
                          select new Student 
                          {
                              Id=r.id,
                              first_name = r.first_name,
                              last_name = r.last_name,
                              age=r.age,
                              dob=r.dob,
                              address = r.address,
                              state = r.state,
                              sex=r.sex,
                              country = r.country,
                              subject = r.subject
                          };
            var a = Json(student.OrderBy(sidx + " " + sord).ToJqGridData(page, rows, null, search,
               new[] { "Id", "first_name", "last_name", "age", "dob", "address", "state", "sex", "country", "subject" }), JsonRequestBehavior.AllowGet);
            return Json(student.OrderBy(sidx + " " + sord).ToJqGridData(page, rows, null, search,
               new[] { "Id","first_name", "last_name","age","dob", "address", "state","sex", "country", "subject" }), JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Delete(int id)
        {
            StudentDBEntities DB = new StudentDBEntities();
            var stu= (from r in DB.studentDetails 
                     where r.id==id
                     select r).First();

            if (stu != null)
            {
                DB.DeleteObject(stu);
                DB.SaveChanges();
            }
            else
            {
                Response.StatusCode = 500;
                return Content("Record not found.");
            }
            return Json(true);
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(string first_name, string last_name,string age,string dob, string address, string state,string sex, string country, string subject)
        {
            StudentDBEntities DB = new StudentDBEntities();
            studentDetail std = new studentDetail();
            std.first_name = first_name;
            std.last_name = last_name;
            std.address = address;
            std.state = state;
            std.age = Convert.ToInt32(age);
            std.sex  = Convert.ToInt32(sex);
            std.country = country;
            std.dob = System.DateTime.Now;
            std.country = country;
            std.country = country;
            std.subject = subject;
            DB.AddTostudentDetails(std);
            DB.SaveChanges();
            return Json(true);
        }
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Here is the javascript function for add , edit search ,and delete<br />
<code><br />
GridDemo.Home.GridDemo = {</p>
<p>    setupGrid: function (grid, pager, search) {<br />
        grid.jqGrid({<br />
            datatype: 'json',<br />
            mtype: 'GET',<br />
            viewrecords: true,<br />
            colNames: ['Id','first_name', 'Last Name','age','dob','Address', 'State','sex' ,'Country', 'Subject'],<br />
            colModel: [<br />
                        { name: 'Id', index: 'Id', width: 75, editable: false, editoptions: { readonly: true, size: 10} },<br />
                        { name: 'first_name', index: 'first_name', width: 100, editable: true, editoptions: { size: 10}, editrules: { required: true}},<br />
                        { name: 'last_name', index: 'last_name', width: 100, editable: true, editoptions: { size: 10 }, editrules: { required: true} },<br />
                        { name: 'age', index: 'age', width: 70, editable: true, editoptions: { size: 10 }, editrules: { required: true} },<br />
                        { name: new Date('dob'), index: new Date('dob'), width: 100, editable: true, editoptions: { size: 10 }, editrules: { required: true} },<br />
                        { name: 'address', index: 'address', width: 100, editable: true, editoptions: { size: 10}, editrules: { required: true}},<br />
                        { name: 'state', index: 'state', width: 70, editable: true, editoptions: { size: 10 }, editrules: { required: true} },<br />
                         { name: 'sex', index: 'sex', width: 70, editable: true, editoptions: { size: 10 }, editrules: { required: true} },<br />
                        { name: 'country', index: 'country', width: 70, editable: true, editoptions: { size: 10}, editrules: { required: true}},<br />
                        { name: 'subject', index: 'subject', width: 70, editable: true, editoptions: { size: 10}, editrules: { required: true}}<br />
                      ],<br />
            pager: pager,<br />
            sortname: &#8216;first_name&#8217;,<br />
            rowNum: 10,<br />
            rowList: [10, 20, 50],<br />
            sortorder: "asc",<br />
            url: "GridStudentDate"<br />
        }).navGrid(pager, { edit: true, add: true, del: true, search: false }, { url: "Create" }, { url: "Create" }, { url: "Delete" });</p>
<p>        search.filterGrid("#" + grid.attr("id"), {<br />
            gridModel: false,<br />
            filterModel: [{<br />
                label: 'Search',<br />
                name: 'search',<br />
                stype: 'text'<br />
            }]<br />
        });<br />
    }<br />
};<br />
</code><br />
=======================<br />
Now these are the Server Side Method to call these function &#8211;<br />
<code><br />
public ActionResult GridStudentDate(int page, int rows, string search, string sidx, string sord)<br />
        {<br />
            sidx = "first_name";<br />
            StudentDBEntities DB = new StudentDBEntities();<br />
            var student = from r in DB.studentDetails<br />
                          select new Student<br />
                          {<br />
                              Id=r.id,<br />
                              first_name = r.first_name,<br />
                              last_name = r.last_name,<br />
                              age=r.age,<br />
                              dob=r.dob,<br />
                              address = r.address,<br />
                              state = r.state,<br />
                              sex=r.sex,<br />
                              country = r.country,<br />
                              subject = r.subject<br />
                          };<br />
            var a = Json(student.OrderBy(sidx + " " + sord).ToJqGridData(page, rows, null, search,<br />
               new[] { "Id", "first_name", "last_name", "age", "dob", "address", "state", "sex", "country", "subject" }), JsonRequestBehavior.AllowGet);<br />
            return Json(student.OrderBy(sidx + " " + sord).ToJqGridData(page, rows, null, search,<br />
               new[] { "Id","first_name", "last_name","age","dob", "address", "state","sex", "country", "subject" }), JsonRequestBehavior.AllowGet);<br />
        }</p>
<p>        [AcceptVerbs(HttpVerbs.Post)]<br />
        public ActionResult Delete(int id)<br />
        {<br />
            StudentDBEntities DB = new StudentDBEntities();<br />
            var stu= (from r in DB.studentDetails<br />
                     where r.id==id<br />
                     select r).First();</p>
<p>            if (stu != null)<br />
            {<br />
                DB.DeleteObject(stu);<br />
                DB.SaveChanges();<br />
            }<br />
            else<br />
            {<br />
                Response.StatusCode = 500;<br />
                return Content("Record not found.");<br />
            }<br />
            return Json(true);<br />
        }<br />
        [AcceptVerbs(HttpVerbs.Post)]<br />
        public ActionResult Create(string first_name, string last_name,string age,string dob, string address, string state,string sex, string country, string subject)<br />
        {<br />
            StudentDBEntities DB = new StudentDBEntities();<br />
            studentDetail std = new studentDetail();<br />
            std.first_name = first_name;<br />
            std.last_name = last_name;<br />
            std.address = address;<br />
            std.state = state;<br />
            std.age = Convert.ToInt32(age);<br />
            std.sex  = Convert.ToInt32(sex);<br />
            std.country = country;<br />
            std.dob = System.DateTime.Now;<br />
            std.country = country;<br />
            std.country = country;<br />
            std.subject = subject;<br />
            DB.AddTostudentDetails(std);<br />
            DB.SaveChanges();<br />
            return Json(true);<br />
        }<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-27675</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Thu, 28 Apr 2011 20:31:07 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-27675</guid>
		<description>Patrick, "better suited" is in the eye of the beholder, no? 

But yes, generally speaking StartsWith can use an index, but Contains can't. Your DB may vary.</description>
		<content:encoded><![CDATA[<p>Patrick, "better suited" is in the eye of the beholder, no? </p>
<p>But yes, generally speaking StartsWith can use an index, but Contains can&#8217;t. Your DB may vary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick M-A</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-27635</link>
		<dc:creator>Patrick M-A</dc:creator>
		<pubDate>Thu, 28 Apr 2011 08:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-27635</guid>
		<description>Thank you for this , i have i have been searching for ways to elegantly search all fields .Perfect.

Just one question tho, why in the ListAddSearchQuery are u building a string using StartWith(), when surely Contains() is better suited for a generic search function. Is there performance penalties ?</description>
		<content:encoded><![CDATA[<p>Thank you for this , i have i have been searching for ways to elegantly search all fields .Perfect.</p>
<p>Just one question tho, why in the ListAddSearchQuery are u building a string using StartWith(), when surely Contains() is better suited for a generic search function. Is there performance penalties ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-22396</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Tue, 18 Jan 2011 20:31:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-22396</guid>
		<description>FWIW, the shared folders are different "feature" is not in .NET 4.</description>
		<content:encoded><![CDATA[<p>FWIW, the shared folders are different "feature" is not in .NET 4.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eric</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-22395</link>
		<dc:creator>eric</dc:creator>
		<pubDate>Tue, 18 Jan 2011 20:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-22395</guid>
		<description>Actually it's something even more simple.

The project was loaded on a shared drive and this will occur for LOCALHOST for testing.

Solution:  Move the folder to the local drive.

Sheesh.  wish I could get my 2 hours back.

thanks</description>
		<content:encoded><![CDATA[<p>Actually it&#8217;s something even more simple.</p>
<p>The project was loaded on a shared drive and this will occur for LOCALHOST for testing.</p>
<p>Solution:  Move the folder to the local drive.</p>
<p>Sheesh.  wish I could get my 2 hours back.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-22393</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Tue, 18 Jan 2011 19:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-22393</guid>
		<description>Eric, have you Googled that message? Seems you need to change your IIS App pool security settings.</description>
		<content:encoded><![CDATA[<p>Eric, have you Googled that message? Seems you need to change your IIS App pool security settings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eric</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-22392</link>
		<dc:creator>eric</dc:creator>
		<pubDate>Tue, 18 Jan 2011 19:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-22392</guid>
		<description>Security Exception:

I'm getting this error:
System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Any clue.  I didn't make any changes to anything in the project.  I cleaned and rebuilt and this continued to occur</description>
		<content:encoded><![CDATA[<p>Security Exception:</p>
<p>I&#8217;m getting this error:<br />
System.Security.SecurityException: Request for the permission of type &#8216;System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242; failed.</p>
<p>Any clue.  I didn&#8217;t make any changes to anything in the project.  I cleaned and rebuilt and this continued to occur</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rooban</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-18689</link>
		<dc:creator>Rooban</dc:creator>
		<pubDate>Wed, 29 Sep 2010 06:15:41 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-18689</guid>
		<description>Hi, this is great series. thanks. but i have one question: how to display search filter not like "google-style". i want some thing similar to the first image where in user can search with more than one criteria. how to enable it?

Waiting for your response</description>
		<content:encoded><![CDATA[<p>Hi, this is great series. thanks. but i have one question: how to display search filter not like "google-style". i want some thing similar to the first image where in user can search with more than one criteria. how to enable it?</p>
<p>Waiting for your response</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Vinge</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-18143</link>
		<dc:creator>Steve Vinge</dc:creator>
		<pubDate>Sat, 04 Sep 2010 17:02:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-18143</guid>
		<description>OR 
Json(pageModel, JsonRequestBehavior.AllowGet)</description>
		<content:encoded><![CDATA[<p>OR<br />
Json(pageModel, JsonRequestBehavior.AllowGet)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Vinge</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/27/38243/#comment-18142</link>
		<dc:creator>Steve Vinge</dc:creator>
		<pubDate>Sat, 04 Sep 2010 16:53:59 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38243#comment-18142</guid>
		<description>Thanks. 

FYI, When upgrading your demo to VS2010, I had to add:
 mtype: 'POST' 
to the jqGrid stmt in the Home.GridDemo.js file for it to load data.</description>
		<content:encoded><![CDATA[<p>Thanks. </p>
<p>FYI, When upgrading your demo to VS2010, I had to add:<br />
 mtype: &#8216;POST&#8217;<br />
to the jqGrid stmt in the Home.GridDemo.js file for it to load data.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

