Can you recommend a straightforward way or tell me how to fix the workaround?
I want an ObjectDataSource to have a parameter linked to the value of a CheckBox ("chkShowInactivesInGrid") that is inside a CommandItemTemplate.
Is there any way for the ObjectDataSource to refer to this CheckBox? (I get "not found" error.)
As a workaround I use for the parameter a CheckBox "chkShowInactive" that is on the web page, NOT inside a CommandItemTemplate.
<SelectParameters>
<asp:ControlParameter Name="DisplayInactive" ControlID="chkShowInactive" PropertyName="Checked" />
....
<CommandItemTemplate>
<div style="padding: 10px 0px;">
<asp:CheckBox ID="chkShowInactivesInGrid" Text="Show Inactive" runat="server" />
</div>
</CommandItemTemplate>
In this workaround I hope to have the CheckBox inside CommandItemTemplate ("chkShowInactivesInGrid" ) mirror the value of the other checkbox.
I can set the value of "chkShowInactivesInGrid" using the following, BUT this event fires ONLY when the page (actually the user control) is first displayed.
When the page containing the user control is refreshed, the chkShowInactive may have a new value but this value is not transferred to chkShowInactivesInGrid because
the following event is not fired.
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
PopulateOnPrerender = false;
if (e.Item is GridCommandItem)
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
CheckBox cb = (CheckBox)cmditm.FindControl("chkShowInactivesInGrid");
cb.Checked = chkShowInactive.Checked;
}
}
| foreach (Control ctl in pnlMain.Controls) |
| { |
| if(ctl.GetType() == typeof(TextBox)) |
| { |
| ((WebControl)ctl).Attributes.Add("onfocus", "this.className='textBoxActive'"); |
| ((WebControl)ctl).Attributes.Add("onblur", "this.className='textBox'"); |
| } |
| else if(ctl.GetType() == typeof(RadNumericTextBox)) |
| { |
| ((RadNumericTextBox)ctl).FocusedStyle.BorderWidth = 2; |
| ((RadNumericTextBox) ctl).FocusedStyle.BorderColor = Color.DarkSlateBlue; |
| } |
| else if(ctl.GetType() == typeof(RadMaskedTextBox)) |
| { |
| ((RadMaskedTextBox)ctl).FocusedStyle.BorderWidth = 2; |
| ((RadMaskedTextBox)ctl).FocusedStyle.BorderColor = Color.DarkSlateBlue; |
| } |
| } |
| Dim dt As Data.DataTable | |
| dt = dbobj.CreateDT(strsql, JobMastModel.DBClasses.DBTools.DB.DW) | |
| RadGrid1.DataSource = dt | |
| RadGrid1.DataBind() | |
| dbobj.DBConnMain.JMConnection.Close() | |
| 'Detail table (has files) | |
| Dim dtFiles As Data.DataTable | |
| Dim files As Telerik.Web.UI.GridTableView = New Telerik.Web.UI.GridTableView | |
| Dim strFile As String | |
| strFile = "SELECT * from tblDGdrawings WHERE dg_id = '" & dt.Rows(0).Item("id") & "'" | |
| dtFiles = dbobj.CreateDT(strFile, JobMastModel.DBClasses.DBTools.DB.DW) | |
| files.DataSource = dtFiles | |
| RadGrid1.MasterTableView.DetailTables.Add(files) |
| <a href="#" onclick="openRadWindow('<%# Eval("EntryId") %>'); return false;">Details</a> |
| <script type="text/javascript"> |
| function OpenPositionedWindow(oButton, url, windowName) |
| { |
| var oWnd = window.radopen(url,windowName); |
| } |
| function openRadWindow(EntryId) |
| { |
| var oWnd = radopen("Questions.aspx?ID=" + EntryId, "RadWindow1" ); |
| oWnd.Center(); |
| } |
| </script> |
I have a large rad tree view that is fully expanded with checkboxes enabled.
The problem I have is that this type of UI makes it hard for users to see which items are checked. The checkbox is small and the text does not show as being selected so the user has to scan each item to see if it is checked.
So I want to hightlight the checked nodes.
There appears to be a difference between the Server + Client setting of the CSS for nodes. On page load I set the css class by ServerSide and then when the user checks or unchecks on the client side I set it using client side events.
Server Side
RadTreeNode node = RadTreeView1.FindNodeByValue(ID);
node.CssClass = "RadNodeSelected";
Client Side
var node = eventArgs.get_node();
node.set_cssClass("RadNodeSelected");
If you make the cssClass "RadNodeSelected" have something like the following you really see the issue I have.
.RadNodeSelected
{
font-weight: bold;
color: Purple;
border : Red dotted 5px;
}
This is what is rendered from the server side - as you can see the setting of the cssClass only applies to the SPAN for the text of the node.
<DIV class=rtTop><SPAN class=rtSp></SPAN><SPAN class=rtMinus></SPAN><INPUT
class=rtChk type=checkbox CHECKED><SPAN
class="rtIn RadNodeSelected">Trimble</SPAN> </DIV>
and when using the client side to set the CSS it applies to the DIV tag of the node and not the SPAN for the text.
node.set_cssClass("RadNodeSelected");
<DIV class="rtTop rtSelected RadNodeSelected"><SPAN class=rtSp></SPAN><SPAN
class=rtMinus></SPAN><INPUT class=rtChk type=checkbox CHECKED><SPAN
class="rtIn RadNodeSelected">Trimble</SPAN> </DIV>
and client side to remove the CSS
node.set_cssClass(null);
<DIV class="rtTop rtSelected"><SPAN class=rtSp></SPAN><SPAN
class=rtMinus></SPAN><INPUT class=rtChk type=checkbox><SPAN
class="rtIn RadNodeSelected">Trimble</SPAN> </DIV>
I am using RadControls for ASPNET AJAX Q1 2008 and I just noticed a new update for Q2 so I will pull that down and see if it has the same problem.
Am I just using the wrong methods to do what I want or is this a bug?
Chris