iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello,
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.
I have been through the examples in the forum, and have tried using
But the problem is that with the above code, I can see in the rendered HTML, there is a tag added for "onclick='return CheckForExclude(this)' for each of the checkboxes in the column, however, the javascript function does not get called. Instead if I delete the existing onCLick setting and re add exacty the same using firebug, or IE developer toolbar, javascript function is invoked.
Instead, if I use e.Row.Cells.GetNamedItem("CheckBoxColumn").CustomAttributes = "onclick = 'return CheckForMultipleExclude(this);'";, it works perfectly , but this gets called also for the entire 'td' within which the checkbox is rendered. Kindly help me. Thanks DHaval.
Kindly help me.
Thanks
DHaval.
Hi Dhaval,CustomAttributes properties in e.Row.Cells.GetNamedItem("CheckBoxColumn"), is not attached an event to your checkbox include "onclick", "onmousedown", "onmouseup" and the other client side event.
It will only attached event in a cell properties, not checkbox object. So, no matter your tried, it will attach into "td" element that you said.e.g try to call alert in those events. With or without AllowEdit>> If you select the cell (not click the checkbox), the alert will show.So, onmouseup and onmousedown event are also not suggested workaround.If you want to have an event for a checkbox object, I suggested you to use a cell template.You can place your own checkbox control in template. With this way, you can use all event that already inside that checkbox.Since your checkbox is using database, I think you would also need to validate it. You will need to handle the check/uncheck state.
Regards,Handy
I made a test of your reported scenario by creating a simple test page based on your information.
The result of the test is same as yours. Adding ‘onclick’ by using CustomObjectAttributes does causing the javascript function not get called. After going deeper checking into this behavior, I found out that if ‘AllowEdit’ is disabled, the ‘onclick’ event that is added by using CustomObjectAttributes works, the javascript function get called.
Due to the information I got from WebGrid development team, the onclick event is exclusively used by WebGrid editing feature.
There is a workaround for this scenario. You may try to use the onmousedown event (or onmouseup event). I have tested that the onmousedown and onmouseup event in my simple test page and it works.
Hope this helps.
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.
The code I am using is
{
if (data.checked) {data.checked =
}
grid.AddInput("Operation", "MultipleExclude");
grid.AddInput("Exclude", "True"); }
grid.AddInput("Exclude", "False"); } grid.SetStatus1(
grid.SendCustomRequest();
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname