<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: How to edit  and save multiple rows in jqgrid</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>hariom964 on How to edit  and save multiple rows in jqgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid#p7864</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid#p7864</guid>
        	        	<description><![CDATA[<blockquote>
<p>tony said:</p>
<p>Hello,</p>
<p>What do you use inline edit, cell edit or form edit?</p>
<p>If you use cell editing you can use clientArray in the url and then getChangedCells method.</p>
<p>Regasrds</p>
</p>
<p>Tony</p>
</blockquote>
<hr />
<p>Thanks Tony,</p>
<p>I am using cell edit. I am very new to jquery and jqgrid. Can you please give a suitable example with some code to implement it in asp.net mvc or any other better. Following is my view code(Index.aspx)</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160;jQuery(document).ready(function() {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;jQuery("#list").jqGrid({</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;url: &#39;/Home/GetGridData/&#39;,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datatype: &#39;json&#39;,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;mtype: &#39;POST&#39;,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;colNames: [&#39;Customer ID&#39;, &#39;Contact Name&#39;, &#39;Address&#39;, &#39;City&#39;, &#39;Postal Code&#39;],</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;colModel: [</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;{ name: &#39;CustomerID&#39;, index: &#39;CustomerID&#39;, width: 100, align: &#39;left&#39;, editable: true },</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;{ name: &#39;ContactName&#39;, index: &#39;ContactName&#39;, width: 150, align: &#39;left&#39;, editable: true },</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;{ name: &#39;Address&#39;, index: &#39;Address&#39;, width: 300, align: &#39;left&#39;, editable: true },</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;{ name: &#39;City&#39;, index: &#39;City&#39;, width: 150, align: &#39;left&#39;, editable: true },</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;{ name: &#39;PostalCode&#39;, index: &#39;PostalCode&#39;, width: 100, align: &#39;left&#39;, editable: true }</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;],</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;rowNum: 10,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;rowList: [10, 20, 30],</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;imgpath: &#39;/scripts/themes/sand/images&#39;,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;pager: jQuery(&#39;#pager&#39;),</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;sortname: &#39;CustomerID&#39;,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;viewrecords: true,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;sortorder: "desc",</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;caption: "Cell Edit Example",</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;forceFit: true,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;cellEdit: true,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;cellsubmit: &#39;clientArray&#39;,</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;editurl: "/Home/GridSave",</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;afterEditCell: function(id, name, val, iRow, iCol) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if (name == &#39;invdate&#39;) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;jQuery("#" + iRow + "_invdate", "#celltbl").datepicker({ dateFormat: "yy-mm-dd" });</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;},</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;ondblclickrow: function(id) {&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if (id) {&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; var grid = jquery(&#39;#grid&#39;);&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if(id !== lastsel) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;jquery(&#39;#list&#39;).restorerow(lastsel)&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;jquery(&#39;#list&#39;).editrow(id, true);&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; lastsel = id;&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; else {&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;jquery(&#39;#list&#39;).saverow(lastsel);&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;lastsel = -1;&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; }</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;},&#160;</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;afterSaveCell: function(rowid, name, val, iRow, iCol) { &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160;</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if (name == &#39;amount&#39;) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;var taxval = jQuery("#celltbl").getCell(rowid, iCol + 1);</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;jQuery("#celltbl").setRowData(rowid, { total: parseFloat(val) + parseFloat(taxval) });</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if (name == &#39;tax&#39;) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;var amtval = jQuery("#celltbl").getCell(rowid, iCol - 1);</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;jQuery("#celltbl").setRowData(rowid, { total: parseFloat(val) + parseFloat(amtval) });</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;}) &#160; &#160; &#160; &#160; &#160;&#160;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;.navGrid(pager, { edit: true, add: false, del: true, search: true }, {}, {}, { url: "/Home/Delete" });</p>
<p>&#160;&#160; &#160; &#160; &#160;});</p>
</p>
<p>Following is my Controller code.</p>
</p>
<p>namespace MvcApplication1.Controllers {</p>
<p>&#160;&#160; &#160;[HandleError]</p>
<p>&#160;&#160; &#160;public class HomeController : Controller {</p>
<p>&#160;&#160; &#160; &#160; &#160;public ActionResult Index() {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;ViewData["Message"] = &#8220;Welcome to ASP.NET MVC!&#8221;;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;return View();</p>
<p>&#160;&#160; &#160; &#160; &#160;}</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160;public ActionResult About() {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;return View();</p>
<p>&#160;&#160; &#160; &#160; &#160;}</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160;[AcceptVerbs(HttpVerbs.Post)]</p>
<p>&#160;&#160; &#160; &#160; &#160;public ActionResult GetGridData(string sidx, string sord, int page, int rows) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;return Content(JsonHelper.JsonForJqgrid(GetDataTable(sidx,sord,page,rows), rows, GetTotalCount(), page), &#8220;application/json&#8221;);</p>
<p>&#160;&#160; &#160; &#160; &#160;}</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160;public DataTable GetDataTable(string sidx, string sord, int page, int pageSize) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;int startIndex = (page-1) * pageSize;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;int endIndex = page * pageSize;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;string sql = @&#8221;WITH PAGED_CUSTOMERS &#160;AS</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;(</p>
<p><span> </span> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;SELECT<span> </span> CustomerID, ContactName, Address, City, PostalCode,</p>
<p><span> </span> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;ROW_NUMBER() OVER (ORDER BY &#8221; + sidx + @&#8221; &#8221; + sord + @&#8221;) AS RowNumber</p>
<p><span> </span> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;FROM<span> </span>CUSTOMERS</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;)</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;SELECT<span> </span>CustomerID, ContactName, Address, City, PostalCode</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;FROM<span> </span>PAGED_CUSTOMERS</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;WHERE<span> </span>RowNumber BETWEEN &#8221; + startIndex + @&#8221; AND &#8221; + endIndex + @&#8221;;&#8221;;</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;DataTable dt = new DataTable();</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mainConnection"].ConnectionString);</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;SqlDataAdapter adap = new SqlDataAdapter(sql,conn);</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;var rows=adap.Fill(dt);</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;return dt;</p>
<p>&#160;&#160; &#160; &#160; &#160;}</p>
</p>
<p>&#160;&#160; &#160; &#160; &#160;public int GetTotalCount() {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;string sql = @&#8221;SELECT COUNT(*) FROM Customers&#8221;;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;SqlConnection conn=null;</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;try {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; conn= new SqlConnection(ConfigurationManager.ConnectionStrings["mainConnection"].ConnectionString);</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;SqlCommand comm = new SqlCommand(sql, conn);</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;conn.Open();</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;return (int)comm.ExecuteScalar();</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;} catch {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;} finally {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;try {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if (ConnectionState.Closed != conn.State) {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;conn.Close();</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}catch {</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;}</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160;return -1;</p>
<p>&#160;&#160; &#160; &#160; &#160;}</p>
</p>
<p>&#160;&#160; &#160;}</p>
<p>}</p>
<p>Regards&#160;</p>
<p>Hari</p>
]]></description>
        	        	<pubDate>Thu, 16 Jul 2009 01:50:40 +0300</pubDate>
        </item>
        <item>
        	<title>tony on How to edit  and save multiple rows in jqgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid#p7858</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid#p7858</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>What do you use inline edit, cell edit or form edit?</p>
<p>If you use cell editing you can use clientArray in the url and then getChangedCells method.</p>
<p>Regasrds</p>
</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 16 Jul 2009 01:25:03 +0300</pubDate>
        </item>
        <item>
        	<title>hariom964 on How to edit  and save multiple rows in jqgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid#p7830</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-edit-and-save-multiple-rows-in-jqgrid#p7830</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>I want to edit multiple rows in jqgrid and save them into database by using Asp.net mvc 1.0. Please provide me suitable example for this.</p>
<p>Regards,</p>
<p>Hari</p>
]]></description>
        	        	<pubDate>Wed, 15 Jul 2009 07:17:09 +0300</pubDate>
        </item>
</channel>
</rss>