﻿<?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 - Change style of a row on clientside OnInitializeRow event</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnInitializeRow-GetElement-Null/</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>Change style of a row on clientside OnInitializeRow event</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnInitializeRow-GetElement-Null/</link><pubDate>Wed, 25 Jan 2012 03:44:59 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;Yes, you are correct. By using client data binding means that WebGrid will stripped several processes from the data binding, initialization (including initialize row) and rendering process in server-side.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;The following list describes the new client side events related to client binding feature.&lt;/span&gt;&lt;/p&gt;
&lt;ul style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;&lt;li&gt;OnCustomAggregate – fired when WebGrid needs to perform custom aggregation for column which AggregateType is set to Custom.&lt;/li&gt;&lt;li&gt;OnInitializeRow – fired when a row is initialized.&lt;/li&gt;&lt;li&gt;OnInitializeCell – fired when a row requires synchronization.&lt;/li&gt;&lt;li&gt;OnSynchronizeRow – fired when a row requires synchronization.&lt;/li&gt;&lt;li&gt;OnSynchronizeCell – fired when a cell required synchronization.&lt;/li&gt;&lt;li&gt;OnDataSourceChanged – fired when data source has been changed.&lt;/li&gt;&lt;li&gt;OnDataBound – fired when data binding process is completed.&lt;/li&gt;&lt;li&gt;OnPreRender – fired before WebGrid enters rendering phase.&lt;/li&gt;&lt;li&gt;OnPostRender – fired after rendering operation is completed.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;Using GetElement() method in OnInitializeRow client side event will returns null. This happen because the row element is not available yet. Please try to use the OnSynchronizeRow or OnSynchronizeCell client side event. The GetElement() method doesn’t returns null within this event hence you can reach the style properties.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;You may refer to ClientBinding_BindingEvents.aspx sample file of WebGridSamples project. This sample shows how each row can be customized during data binding process by using client binding events. This sample used OnInitializeRow and OnSynchronizeRow, two of the most frequently used events to perform pre-rendering and post-rendering tasks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;For instances, recent messages are highlighted in dark red color, messages with large attachments are underlined, and unread messages should have its preview row expanded. See ASPX page to learn more about the extensibility enabled by client binding events.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt;"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Change style of a row on clientside OnInitializeRow event</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnInitializeRow-GetElement-Null/</link><pubDate>Tue, 24 Jan 2012 01:41:19 GMT</pubDate><dc:creator>somer@optima.com.tr</dc:creator><description>Dear Yudi,&lt;br /&gt;I'm sorry that i forgot to mention that i'm using clientside binding so i think i have to call clientside OnInitializeRow event on the clientside. In the clientside OnInitializeRow event, i tried to change color, backgroundcolor of a row, or a cell, but not luck.&lt;br /&gt;In the event, GetElement()&amp;nbsp; returning null, so i cant reach style properties. &lt;br /&gt;As a sample code below returning null:&lt;br /&gt;&lt;pre&gt;    &amp;lt;script type="text/javascript"&amp;gt;        function GridOnInitializeRow(controlId, row) {
            alert(row.GetElement());
            return true;
        }
    &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;p&gt;so code below throws exception:&lt;/p&gt;&lt;pre&gt;    &amp;lt;script type="text/javascript"&amp;gt;
        function GridOnInitializeRow(controlId, row) {
            var rowElement = row.GetElement();
            rowElement.style.color = "red";
            return true;
        }
    &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
</description></item><item><title>Change style of a row on clientside OnInitializeRow event</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnInitializeRow-GetElement-Null/</link><pubDate>Mon, 23 Jan 2012 20:39:02 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;To change a row style (background color) depends on a row’s given column’s value is similar to &lt;strong&gt;CustomizeCellAlignment.aspx&lt;/strong&gt; sample file of WebGrid. The sample is available in &lt;strong&gt;WebGridSamples project (start &amp;gt; All Programs &amp;gt; Intersoft WebUI Studio 2011 R2 SP1 &amp;gt; WebUI Studio for ASP.NET &amp;gt; WebGrid 7 &amp;gt; C# or VB Samples)&lt;/strong&gt; or check the live sample at &lt;a href="http://live.intersoftpt.com/cs/WebGrid/CustomizeCellAlignment.aspx?noframe=1"&gt;http://live.intersoftpt.com/cs/WebGrid/CustomizeCellAlignment.aspx?noframe=1&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;The sample demonstrates how to customize cell alignment in WebGrid. In the sample, all of integer columns’s horizontal alignment is set to right-align and programmatically set horizontal alignment to center if the CategoryID is equal to “1” or “7”.&lt;br /&gt;In order to change the background color, please try to use following snippet code.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e)
{
    // do some validation
    if (Convert.ToString(e.Row.Cells.GetNamedItem("CategoryID").Text) == "1" || Convert.ToString(e.Row.Cells.GetNamedItem("CategoryID").Text) == "7")
    {
        ...
        e.Row.Cells.GetNamedItem("SupplierID").Style.BackColor = System.Drawing.Color.Red;
        ...
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Change style of a row on clientside OnInitializeRow event</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnInitializeRow-GetElement-Null/</link><pubDate>Mon, 23 Jan 2012 05:55:40 GMT</pubDate><dc:creator>somer@optima.com.tr</dc:creator><description>&lt;p&gt;I would like change a rows style (background color, etc) depends on a row's given column's value. When I try to get row's element, it returns null; so i cant change style properties.&lt;br /&gt;Can you advise a way to do it? &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>