<?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: LINQ Extensions</title>
	<atom:link href="http://blogs.teamb.com/craigstuntz/2009/04/15/38212/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/</link>
	<description>C# • Entity Framework • Functional Programming • MVC • Web</description>
	<pubDate>Sun, 12 Feb 2012 04:28:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-39425</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Thu, 05 Jan 2012 20:05:27 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-39425</guid>
		<description>Peter,

I know the searchable columns (and their qualified names) from model metadata. I build a string representation of the query and use the DynamicQuery/Dynamic LINQ project from Visual Studio gallery to take that string and turn it into a LINQ predicate.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I know the searchable columns (and their qualified names) from model metadata. I build a string representation of the query and use the DynamicQuery/Dynamic LINQ project from Visual Studio gallery to take that string and turn it into a LINQ predicate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-39423</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Thu, 05 Jan 2012 19:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-39423</guid>
		<description>I have a similar set up with jqgrid being fed by web services back end and linq; Uncanny how much my code is similar to yours - :-)
Im interested in the part
var filteredList = ListAddSearchQuery(baseList, searchQuery, searchColumns);
how did you implement a search strategy to handle any number of search columns operators (and/or) and conditions?</description>
		<content:encoded><![CDATA[<p>I have a similar set up with jqgrid being fed by web services back end and linq; Uncanny how much my code is similar to yours - <img src='http://blogs.teamb.com/craigstuntz/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
Im interested in the part<br />
var filteredList = ListAddSearchQuery(baseList, searchQuery, searchColumns);<br />
how did you implement a search strategy to handle any number of search columns operators (and/or) and conditions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Using jqGrid with ASP.NET MVC &#124; Tuấn&#39;s blog</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-31880</link>
		<dc:creator>Using jqGrid with ASP.NET MVC &#124; Tuấn&#39;s blog</dc:creator>
		<pubDate>Thu, 21 Jul 2011 09:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-31880</guid>
		<description>[...] jqGrid with ASP.NET MVC: Introduction Using jqGrid with ASP.NET MVC: LINQ Extensions  Using jqGrid with ASP.NET MVC: Finally, A Solution  Using jqGrid with ASP.NET MVC: Search and [...]</description>
		<content:encoded><![CDATA[<p>[...] jqGrid with ASP.NET MVC: Introduction Using jqGrid with ASP.NET MVC: LINQ Extensions  Using jqGrid with ASP.NET MVC: Finally, A Solution  Using jqGrid with ASP.NET MVC: Search and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Herman van der Blom</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-26315</link>
		<dc:creator>Herman van der Blom</dc:creator>
		<pubDate>Mon, 04 Apr 2011 18:35:41 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-26315</guid>
		<description>Craig, I got errors when I used poco's in the selects of  IQueryable statements. I had properties in  classes that could not be translated to SQL. I thought as long as they are not used in the query that does not matter, but this piece of code hits those properties :
return new JqGridData()
{
     Page = list.PageIndex,
     Records = list.TotalItemCount,
     Rows = from record in list select record,
     Total = list.PageCount,
     UserData = userData
};
I changed the code: Rows = from record in list select record to:
Rows = list, that works, but what I like to ask you is it right? because I use your code at many places in my webapplication i would like to know if this is right. If I debug your code it iterates over the records. That also seems not to be right, and because you inherites your pagelist from IList and an IList inherites IEnumerate my code seems right. So I hope you can shine some light on this.</description>
		<content:encoded><![CDATA[<p>Craig, I got errors when I used poco&#8217;s in the selects of  IQueryable statements. I had properties in  classes that could not be translated to SQL. I thought as long as they are not used in the query that does not matter, but this piece of code hits those properties :<br />
return new JqGridData()<br />
{<br />
     Page = list.PageIndex,<br />
     Records = list.TotalItemCount,<br />
     Rows = from record in list select record,<br />
     Total = list.PageCount,<br />
     UserData = userData<br />
};<br />
I changed the code: Rows = from record in list select record to:<br />
Rows = list, that works, but what I like to ask you is it right? because I use your code at many places in my webapplication i would like to know if this is right. If I debug your code it iterates over the records. That also seems not to be right, and because you inherites your pagelist from IList and an IList inherites IEnumerate my code seems right. So I hope you can shine some light on this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-18195</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Mon, 06 Sep 2010 21:06:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-18195</guid>
		<description>When you return "hundreds of rows," you use paging.</description>
		<content:encoded><![CDATA[<p>When you return "hundreds of rows," you use paging.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabrizio</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-18194</link>
		<dc:creator>Fabrizio</dc:creator>
		<pubDate>Mon, 06 Sep 2010 21:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-18194</guid>
		<description>Wonderful post, but... repeatitems: false ?
With small pages is fine, but in cases when you may return hundred of rows, may it be a bad chioce ? repeating names in every row are few bits in a row, but multiply 100, 200 and... 

i'm missing something or it's a thing to consider ?
Tks again!</description>
		<content:encoded><![CDATA[<p>Wonderful post, but&#8230; repeatitems: false ?<br />
With small pages is fine, but in cases when you may return hundred of rows, may it be a bad chioce ? repeating names in every row are few bits in a row, but multiply 100, 200 and&#8230; </p>
<p>i&#8217;m missing something or it&#8217;s a thing to consider ?<br />
Tks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerome</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-16365</link>
		<dc:creator>Jerome</dc:creator>
		<pubDate>Fri, 14 May 2010 06:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-16365</guid>
		<description>Hi Craig,

Nice Post. I've been following this along.

Anyway, I'm stuck at something, I'm using stored procedure with .ToJqGridData(), it returns an exception "The query result cannot be enumerated more than once". I don't know how to fix this. Appreciate your help.


Thank you and God Bless.

Regards,

Jerome

&lt;blockquote&gt;&lt;em&gt;&lt;strong&gt;Response: &lt;/strong&gt;&lt;/em&gt; You need a completely different method of paging if your data comes from a proc.&lt;/blockquote&gt;

</description>
		<content:encoded><![CDATA[<p>Hi Craig,</p>
<p>Nice Post. I&#8217;ve been following this along.</p>
<p>Anyway, I&#8217;m stuck at something, I&#8217;m using stored procedure with .ToJqGridData(), it returns an exception "The query result cannot be enumerated more than once". I don&#8217;t know how to fix this. Appreciate your help.</p>
<p>Thank you and God Bless.</p>
<p>Regards,</p>
<p>Jerome</p>
<blockquote><p><em><strong>Response: </strong></em> You need a completely different method of paging if your data comes from a proc.</p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mhoque</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-15646</link>
		<dc:creator>Mhoque</dc:creator>
		<pubDate>Sat, 10 Apr 2010 17:34:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-15646</guid>
		<description>I am using MVC 2 and ToJQGridData having some issues. My Data don't show. With MVC 2 you have to define the  JsonRequestBehavior.AllowGet. That being said from my controller if I use the Following the Data shows on the grid

                var jsonData = new
                {
                    total = totalPages,
                    page = page,
                    records = totalRecords,
                    rows = new[]{
                    new {id = 1, cell = new[] {"1", "Test1", "$99.99", "AGR12345YU1", "$20.00", "VS123UI1"}},
                    new {id = 2, cell = new[] {"2", "Test2", "$199.99", "AGR12345YU2", "$24.00", "VS123UI2"}},
                    new {id = 3, cell = new[] {"3", "Test3", "$945.99", "AGR12345YU3", "$200.00", "VS123UI3"}}
                }
                };

On the other hand if I do the following statement, the data doesn't show.

var result = repository.Select(crit).Items;
                var jsondata = Json(result.AsQueryable().ToJqGridData(page, rows, null, null, null), JsonRequestBehavior.AllowGet);



Any Ideas how to fix this?

&lt;blockquote&gt;&lt;em&gt;&lt;strong&gt;Response:&lt;/strong&gt; If the demo works but your app doesn't, then either you've configured the grid differently, either in terms of your call to jqGrid or setting the grid defaults, or you're returning invalid JSON.&lt;/em&gt;&lt;/blockquote&gt;

</description>
		<content:encoded><![CDATA[<p>I am using MVC 2 and ToJQGridData having some issues. My Data don&#8217;t show. With MVC 2 you have to define the  JsonRequestBehavior.AllowGet. That being said from my controller if I use the Following the Data shows on the grid</p>
<p>                var jsonData = new<br />
                {<br />
                    total = totalPages,<br />
                    page = page,<br />
                    records = totalRecords,<br />
                    rows = new[]{<br />
                    new {id = 1, cell = new[] {"1", "Test1", "$99.99", "AGR12345YU1", "$20.00", "VS123UI1"}},<br />
                    new {id = 2, cell = new[] {"2", "Test2", "$199.99", "AGR12345YU2", "$24.00", "VS123UI2"}},<br />
                    new {id = 3, cell = new[] {"3", "Test3", "$945.99", "AGR12345YU3", "$200.00", "VS123UI3"}}<br />
                }<br />
                };</p>
<p>On the other hand if I do the following statement, the data doesn&#8217;t show.</p>
<p>var result = repository.Select(crit).Items;<br />
                var jsondata = Json(result.AsQueryable().ToJqGridData(page, rows, null, null, null), JsonRequestBehavior.AllowGet);</p>
<p>Any Ideas how to fix this?</p>
<blockquote><p><em><strong>Response:</strong> If the demo works but your app doesn&#8217;t, then either you&#8217;ve configured the grid differently, either in terms of your call to jqGrid or setting the grid defaults, or you&#8217;re returning invalid JSON.</em></p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-13356</link>
		<dc:creator>Ted</dc:creator>
		<pubDate>Thu, 14 Jan 2010 13:35:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-13356</guid>
		<description>I guess I am missing something. Maybe you can set my straight...Great post by the way!

In your post you have ..

When repeatitems is false, the data looks like a regular object in JSON format:

{id:"45678",name:"Speakers",note:"note",stock:"false",ship:"4"}

no quotes. 

&lt;blockquote&gt;&lt;em&gt;&lt;strong&gt;Response:&lt;/strong&gt; Well, that's copied and pasted from the jqGrid documentation. I make no guarantee it's right. :)&lt;/em&gt;&lt;/blockquote&gt;

Here is my example of the return code from my MVC Action Method (public JsonResult GetGridData()) that loads the grid

&lt;code&gt;
//This test works
 		var jsonData = new
            {
                totalpages = 20
              ,
                currpage = 1
              ,
                totalrecords = 500
              ,
                invdata = new[]{
                                    new{Id =23, FirstName = "Ted", LastName="Test"},
                                    new{Id =19, FirstName = "Mark", LastName="Smith"},
                                    new{Id =5, FirstName = "Frank", LastName="Johnson"},
                                    new{Id =46, FirstName = "Bob", LastName="Anderson"}
                                }             
            };


//This one doesn't doesn't because I have quotes around the field names

   string data = JSONHelper.Serialize&#60;IList&#62;(emps);
   //Where data = 
      [{"FirstName":"Bob","Id":1,"LastName":"Smith"},{"FirstName":"mark","Id":2,"LastName":"Johnson"},					{"FirstName":"Steve","Id":3,"LastName":"Anderson"},{"FirstName":"Jim","Id":4,"LastName":"Davis"}]
            //

            var jsonData = new
            {
                totalpages = 20
              ,
                currpage = 1
              ,
                totalrecords = 500
              ,
                invdata = data 
            };
&lt;/code&gt;

&lt;blockquote&gt;&lt;em&gt;&lt;strong&gt;Response:&lt;/strong&gt; Does my demo solution not work for you? Can't you just do what my demo project does?&lt;/em&gt;&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>I guess I am missing something. Maybe you can set my straight&#8230;Great post by the way!</p>
<p>In your post you have ..</p>
<p>When repeatitems is false, the data looks like a regular object in JSON format:</p>
<p>{id:"45678",name:"Speakers",note:"note",stock:"false",ship:"4"}</p>
<p>no quotes. </p>
<blockquote><p><em><strong>Response:</strong> Well, that&#8217;s copied and pasted from the jqGrid documentation. I make no guarantee it&#8217;s right. <img src='http://blogs.teamb.com/craigstuntz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p></blockquote>
<p>Here is my example of the return code from my MVC Action Method (public JsonResult GetGridData()) that loads the grid</p>
<p><code><br />
//This test works<br />
 		var jsonData = new<br />
            {<br />
                totalpages = 20<br />
              ,<br />
                currpage = 1<br />
              ,<br />
                totalrecords = 500<br />
              ,<br />
                invdata = new[]{<br />
                                    new{Id =23, FirstName = "Ted", LastName="Test"},<br />
                                    new{Id =19, FirstName = "Mark", LastName="Smith"},<br />
                                    new{Id =5, FirstName = "Frank", LastName="Johnson"},<br />
                                    new{Id =46, FirstName = "Bob", LastName="Anderson"}<br />
                                }<br />
            };</p>
<p>//This one doesn&#8217;t doesn&#8217;t because I have quotes around the field names</p>
<p>   string data = JSONHelper.Serialize&lt;IList&gt;(emps);<br />
   //Where data =<br />
      [{"FirstName":"Bob","Id":1,"LastName":"Smith"},{"FirstName":"mark","Id":2,"LastName":"Johnson"},					{"FirstName":"Steve","Id":3,"LastName":"Anderson"},{"FirstName":"Jim","Id":4,"LastName":"Davis"}]<br />
            //</p>
<p>            var jsonData = new<br />
            {<br />
                totalpages = 20<br />
              ,<br />
                currpage = 1<br />
              ,<br />
                totalrecords = 500<br />
              ,<br />
                invdata = data<br />
            };<br />
</code></p>
<blockquote><p><em><strong>Response:</strong> Does my demo solution not work for you? Can&#8217;t you just do what my demo project does?</em></p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/04/15/38212/#comment-13355</link>
		<dc:creator>Ted</dc:creator>
		<pubDate>Thu, 14 Jan 2010 12:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38212#comment-13355</guid>
		<description>When I use the Json serializer it puts quotes around my field names ... 
{"FirstName":"John", "LastName":"Smith"} 
How do I serialize my object so that the field names are not in quotes?

Thanks

&lt;blockquote&gt;&lt;em&gt;&lt;strong&gt;Response:&lt;/strong&gt; You don't. &lt;a href="http://www.json.org/example.html" rel="nofollow"&gt;The JSON format requires this.&lt;/a&gt; If it didn't add the quotes, then it wouldn't be JSON.&lt;/em&gt;&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>When I use the Json serializer it puts quotes around my field names &#8230;<br />
{"FirstName":"John", "LastName":"Smith"}<br />
How do I serialize my object so that the field names are not in quotes?</p>
<p>Thanks</p>
<blockquote><p><em><strong>Response:</strong> You don&#8217;t. <a href="http://www.json.org/example.html" rel="nofollow">The JSON format requires this.</a> If it didn&#8217;t add the quotes, then it wouldn&#8217;t be JSON.</em></p></blockquote>
]]></content:encoded>
	</item>
</channel>
</rss>

