﻿<?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 - OnClick using CustomObjectAttribute for checkbox column does not get called</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnClick-using-CustomObjectAttribute-for-checkbox-column-does-not-get-called/</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>OnClick using CustomObjectAttribute for checkbox column does not get called</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnClick-using-CustomObjectAttribute-for-checkbox-column-does-not-get-called/</link><pubDate>Fri, 21 May 2010 13:19:57 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><description>&lt;p&gt;Hi Dhaval,&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-style: normal; font-weight: normal; "&gt;&lt;br /&gt;&lt;/span&gt;CustomAttribute&lt;/i&gt;&lt;/b&gt;s properties in &lt;span style="font-family: 'segoe ui', arial, verdana, tahoma; color: rgb(63, 63, 63); line-height: 18px; "&gt;e.Row.Cells.GetNamedItem("CheckBoxColumn"), is not attached an event to your checkbox include "onclick", "onmousedown", "onmouseup" and the other client side event.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: 'segoe ui', arial, verdana, tahoma; color: rgb(63, 63, 63); line-height: 18px; "&gt;It will only attached event in a &lt;b&gt;cell&lt;/b&gt; properties, not &lt;b&gt;checkbox object&lt;/b&gt;. So, no matter your tried, it will attach into "&lt;b&gt;td&lt;/b&gt;" element that you said.&lt;br /&gt;e.g try to call alert in those events. With or without &lt;b&gt;AllowEdit&amp;gt;&amp;gt; &lt;/b&gt;If you select the cell (not click the checkbox), the alert will show.&lt;br /&gt;&lt;br /&gt;So, &lt;b&gt;onmouseup&lt;/b&gt;&amp;nbsp;and &lt;b&gt;onmousedown&lt;/b&gt;&amp;nbsp;event are also not suggested workaround.&lt;br /&gt;If you want to have an event for a checkbox object, I suggested you to use a cell template.&lt;br /&gt;You can place your own &lt;b&gt;checkbox &lt;/b&gt;control in template. With this way, you can use all event that already inside that checkbox.&lt;br /&gt;Since your checkbox is using database, I think you would also need to validate it. You will need to handle the check/uncheck state.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui', arial, verdana, tahoma; color: rgb(63, 63, 63); line-height: 18px; "&gt;Regards,&lt;br /&gt;Handy&lt;/span&gt;&lt;/p&gt;</description></item><item><title>OnClick using CustomObjectAttribute for checkbox column does not get called</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnClick-using-CustomObjectAttribute-for-checkbox-column-does-not-get-called/</link><pubDate>Fri, 21 May 2010 07:40:33 GMT</pubDate><dc:creator>dhavalv</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have now used the "onmousedownevent" with the custom object attribute. But now the problem is that the grid no longer recognizes that row as being edited, after I change the status for the checkbox. As a result , "OnTheFlyPostBack" does not happen for row updates, which would otherwise happen as soon as I navigate away from the row.&lt;/p&gt;
&lt;p&gt;The code I am using is &lt;/p&gt;&lt;span style="font-size: 13px"&gt;maExcludeCell.CustomObjectAttributes = &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"onmousedown = 'return CheckForMultipleExclude(this);'"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;;&lt;/span&gt;

&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt; &lt;/p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; CheckForMultipleExclude(data) 

&lt;p&gt;{&lt;/p&gt;
&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; grid = ISGetObject(&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"WebGridMain"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);
&lt;/span&gt;&lt;span style="font-size: 13px"&gt;

&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;/span&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; (data.checked) {data.checked = &lt;/span&gt;&lt;/p&gt;data.checked = &lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;;

&lt;p&gt;}&lt;/p&gt;
&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; {

data.checked = &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;;

&lt;p&gt;}&lt;/p&gt;
&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; exclude = data.checked;


&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; proceed = confirm(&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Would you like to apply your 'Exclude' changes to all three subjects ? Click 'OK' to modify all, or 'Cancel' to modify just the current subject."&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);


&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; (proceed) 

&lt;p&gt;{ &lt;/p&gt;

&lt;p&gt;grid.AddInput(&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Operation"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"MultipleExclude"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);
&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Operation"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"MultipleExclude"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);
&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; (exclude) {

&lt;p&gt;grid.AddInput(&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Exclude"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"True"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);
&lt;p&gt;}&lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Exclude"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"True"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);
&lt;p&gt;}&lt;/p&gt;
&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; {

&lt;p&gt;grid.AddInput(&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Exclude"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"False"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);
&lt;p&gt;}&lt;/p&gt;
grid.SetStatus1(&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Exclude"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"False"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);
&lt;p&gt;}&lt;/p&gt;
grid.SetStatus1(&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"Updating .... "&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);

&lt;p&gt;grid.SendCustomRequest();&lt;/p&gt;
&lt;/span&gt;&lt;span style="color: #008000; font-size: 13px"&gt;&lt;span style="color: #008000; font-size: 13px"&gt;//Takes the current status bar message and assigns it to tooltip&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;
setTimeout(&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"return SetGridStatusBarToolTip();"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, 0);

&lt;p&gt;} &lt;/p&gt;
&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;;

&lt;p&gt;}&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;</description></item><item><title>OnClick using CustomObjectAttribute for checkbox column does not get called</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnClick-using-CustomObjectAttribute-for-checkbox-column-does-not-get-called/</link><pubDate>Fri, 21 May 2010 05:41:05 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;I made a test of your reported scenario by creating a simple test page based on your information.&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 result of the test is same as yours. Adding ‘&lt;em&gt;onclick’&lt;/em&gt; by using &lt;em&gt;CustomObjectAttributes&lt;/em&gt; does causing the javascript function not get called. After going deeper checking into this behavior, I found out that if ‘&lt;em&gt;AllowEdit’&lt;/em&gt; is &lt;em&gt;disabled&lt;/em&gt;, the ‘&lt;em&gt;onclick’&lt;/em&gt; event that is added by using &lt;em&gt;CustomObjectAttributes&lt;/em&gt; works, the javascript function get called.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Due to the information I got from WebGrid development team, the onclick event is exclusively used by WebGrid editing feature.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;There is a workaround for this scenario. You may try to use the &lt;em&gt;onmousedown&lt;/em&gt; event (or &lt;em&gt;onmouseup&lt;/em&gt; event). I have tested that the &lt;em&gt;onmousedown&lt;/em&gt; and &lt;em&gt;onmouseup&lt;/em&gt; event in my simple test page and it works.&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>OnClick using CustomObjectAttribute for checkbox column does not get called</title><link>http://www.intersoftsolutions.com/Community/WebGrid/OnClick-using-CustomObjectAttribute-for-checkbox-column-does-not-get-called/</link><pubDate>Thu, 20 May 2010 19:47:39 GMT</pubDate><dc:creator>dhavalv</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am using Webgrid 7. The grid has a check box column, and I am wanting to attach a client side "onclick" java script function for the check box column.&lt;/p&gt;
&lt;p&gt;I have been through the examples in the forum, and have tried using&lt;/p&gt;&lt;span style="font-size: 13px"&gt;e.Row.Cells.GetNamedItem("CheckBoxColumn").CustomObjectAttributes = &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"onclick = 'return CheckForMultipleExclude(this);'"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;;&lt;/span&gt; 

&lt;p&gt;&lt;span style="font-size: 13px"&gt;But the problem is that with the above code, I can see in the &lt;/span&gt;&lt;span style="font-size: 13px"&gt;rendered HTML, there is a tag added for "onclick='return CheckForExclude(this)' for each of the checkboxes in the column, however, the javascript &lt;/span&gt;&lt;span style="font-size: 13px"&gt;function does not get called. Instead if I delete the existing onCLick setting&amp;nbsp;and re add exacty the same using firebug, or IE developer toolbar,&amp;nbsp;javascript function is&amp;nbsp;invoked.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;Instead, if I use &lt;span style="font-size: 13px"&gt;e.Row.Cells.GetNamedItem("CheckBoxColumn").CustomAttributes = &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"onclick = 'return CheckForMultipleExclude(this);'"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;;, it works perfectly , but this gets called also for the entire 'td' within which the checkbox is rendered.&lt;/span&gt; 

&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Kindly help me.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;DHaval.&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;
e.Row.Cells.GetNamedItem("CheckBoxColumn").CustomAttributes = &lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"onclick = 'return CheckForMultipleExclude(this);'"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;;, it works perfectly , but this gets called also for the entire 'td' within which the checkbox is rendered.&lt;/span&gt; 

&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Kindly help me.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;DHaval.&lt;/p&gt;</description></item></channel></rss>