﻿<?xml version="1.0" encoding="utf-8"?><rss 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:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - ClientBinding, BatchUpdate, and JavaScript</title><link>http://www.intersoftsolutions.com/Community/WebGrid/ClientBinding-BatchUpdate-and-JavaScript/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>ClientBinding, BatchUpdate, and JavaScript</title><link>http://www.intersoftsolutions.com/Community/WebGrid/ClientBinding-BatchUpdate-and-JavaScript/</link><pubDate>Sat, 22 Aug 2009 02:41:41 GMT</pubDate><dc:creator>james</dc:creator><description>&lt;p&gt;Dan,&lt;/p&gt;&lt;p&gt;Could you check what's the ColumnType of the cell that contains the image?&lt;/p&gt;
&lt;p&gt;AFAIK, the SetImage method should work well for &lt;b&gt;Image&lt;/b&gt; and &lt;b&gt;ImageAndText&lt;/b&gt; column type. This method is also used in BatchUpdate_AllowReview sample, so it suppose to work fine.&lt;/p&gt;</description></item><item><title>ClientBinding, BatchUpdate, and JavaScript</title><link>http://www.intersoftsolutions.com/Community/WebGrid/ClientBinding-BatchUpdate-and-JavaScript/</link><pubDate>Fri, 21 Aug 2009 14:07:44 GMT</pubDate><dc:creator>danjransom@gmail.com</dc:creator><description>&lt;p&gt;Thanks. The SetImage method didn't work for me, but the CellElement version did. Note: the  plus signs ( ) are missing from the for loop in the code block and this caused an infinate JavaScript loop.&lt;/p&gt;</description></item><item><title>ClientBinding, BatchUpdate, and JavaScript</title><link>http://www.intersoftsolutions.com/Community/WebGrid/ClientBinding-BatchUpdate-and-JavaScript/</link><pubDate>Fri, 21 Aug 2009 10:01:50 GMT</pubDate><dc:creator>james</dc:creator><description>&lt;p&gt;Instead of accessing the image element manually, you can also try using cell.SetImage method.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;cell.SetImage("images/Anne.jpg");&lt;/pre&gt;
&lt;p&gt;This way, your code looks much elegant and clean.&lt;/p&gt;
&lt;p&gt;- James.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>ClientBinding, BatchUpdate, and JavaScript</title><link>http://www.intersoftsolutions.com/Community/WebGrid/ClientBinding-BatchUpdate-and-JavaScript/</link><pubDate>Fri, 21 Aug 2009 00:37:58 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;Here are the code in your previous post&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;asp:Button runat="server" Text="Change Image" OnClientClick="changeImage(); return false;" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&lt;br /&gt;function changeImage() {&lt;br /&gt;&lt;br /&gt;     var grid = ISGetObject('WebGrid1');&lt;br /&gt;&lt;br /&gt;     var selectedObject = grid.GetSelectedObject();&lt;br /&gt;&lt;br /&gt;     if (selectedObject != null) {&lt;br /&gt;&lt;br /&gt;          var selectedRow = selectedObject.ToRowObject();&lt;br /&gt;&lt;br /&gt;          if (selectedRow.Type == "Record") {&lt;br /&gt;&lt;br /&gt;               var cells = selectedRow.GetCells();&lt;br /&gt;&lt;br /&gt;               var ncColumnPhoto = cells.GetNamedItem("ColumnPhoto");&lt;br /&gt;&lt;br /&gt;               ncColumnPhoto.SetText("images/Anne.jpg");&lt;br /&gt;&lt;br /&gt;               selectedRow.SetForceNoEdit(true);&lt;br /&gt;&lt;br /&gt;               selectedRow.GetElement().style.backgroundColor = "LightCyan";&lt;br /&gt;&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;else {&lt;br /&gt;&lt;br /&gt;        alert('Please select a row');&lt;br /&gt;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;In order to update image in the column you will need to access the image HTML element and modify the src property.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;The SetForceNoEdit function has worked if we already set the Grid to AllowEdit, after changeImage function is invoked the row will not be editable.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;In order to change the background color of the row you will need to modify all the TD element background color of all the selected row.  &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Here is the updated snippet: &lt;br /&gt;&lt;/p&gt;&lt;pre&gt;function changeImage() {&lt;br /&gt;&lt;br /&gt;    var grid = ISGetObject('WebGrid1');&lt;br /&gt;    var selectedObject = grid.GetSelectedObject();&lt;br /&gt;    if (selectedObject != null) {&lt;br /&gt;        var selectedRow = selectedObject.ToRowObject();&lt;br /&gt;        if (selectedRow.Type == "Record") {&lt;br /&gt;            debugger;&lt;br /&gt;            var cells = selectedRow.GetCells();&lt;br /&gt;            var ncColumnPhoto = cells.GetNamedItem("ColumnPhoto");&lt;br /&gt;            ncColumnPhoto.CellElement.getElementsByTagName('img')[0].src = "images/Anne.jpg";&lt;br /&gt;            selectedRow.SetForceNoEdit(true);&lt;br /&gt;&lt;br /&gt;            var columnList = selectedRow.GetElement().getElementsByTagName('td');&lt;br /&gt;&lt;br /&gt;            for (var i = 1; i &amp;lt; columnList.length; i  ) {&lt;br /&gt;                columnList[i].style.backgroundColor = "LightCyan";&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        alert('Please select a row');&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>ClientBinding, BatchUpdate, and JavaScript</title><link>http://www.intersoftsolutions.com/Community/WebGrid/ClientBinding-BatchUpdate-and-JavaScript/</link><pubDate>Thu, 20 Aug 2009 15:10:08 GMT</pubDate><dc:creator>danjransom@gmail.com</dc:creator><description>&lt;p&gt;&lt;p&gt;* Apparently this forum behaves very badly when script is pasted directly into the edit window rather than using the "insert code" feature.&amp;nbsp;&lt;/p&gt;&lt;p&gt;We are using a grid that has ClientBinding and BatchUpdate enabled and are trying to make changes using JavaScript without sucess. we do not want to post back to the server. Here's what we need:&lt;/p&gt;&lt;p&gt;1. Update the image in an image colum&lt;/p&gt;&lt;p&gt;2. Set a row as uneditable (SetForceNoEdit)&lt;/p&gt;&lt;p&gt;3. Change the background color of a row.&lt;/p&gt;&lt;p&gt;How can we accomplish this?&lt;/p&gt;&lt;/p&gt;</description></item></channel></rss>