Hello Team,
I have searched over the forum to get a solution but I am finding my issue is quite different than what I have found so far.
I have grid of users that will be selected with a clientselectcolumn and I have a separate template column of checkboxs that I want to set only one of the selected users as the main user or admin user. I need help to achieve the following:
1. Client side validation to allow only one checkbox to be selected at a time for the admin user when a checkbox is selected.
2. Persist the checked state of checked box upon paging or sorting.
Could you please point me in to some sources or provide me with pointers.
Thank you.
-G-
I have searched over the forum to get a solution but I am finding my issue is quite different than what I have found so far.
I have grid of users that will be selected with a clientselectcolumn and I have a separate template column of checkboxs that I want to set only one of the selected users as the main user or admin user. I need help to achieve the following:
1. Client side validation to allow only one checkbox to be selected at a time for the admin user when a checkbox is selected.
2. Persist the checked state of checked box upon paging or sorting.
Could you please point me in to some sources or provide me with pointers.
Thank you.
-G-
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 16 Aug 2010, 06:21 AM
Hello,
Here are some documentation links which would help you to get started.
Persisting the selected rows server-side on sorting/paging/filtering/grouping
Persisting CheckBox control state in GridTemplateColumn on rebind
-Shinu.
Here are some documentation links which would help you to get started.
Persisting the selected rows server-side on sorting/paging/filtering/grouping
Persisting CheckBox control state in GridTemplateColumn on rebind
-Shinu.
0
Rafaga2k
Top achievements
Rank 1
answered on 17 Nov 2010, 06:34 PM
i have similar problems but i'm doing this purelly in code, i've serached througth the entire forums but no success.
in the forums there are tons of checkbox problems but the code is made in design mode not in execution time
i'm in the point that :
1) implemented the template using ITemplate interface in a custom made class
2) Inside i declared a Checkbox with Autopostback=true
3) captured the event raised by the check box internally in the class and realuching if was generated by the class itself
5) Used The template in ItemTemplate property in the GridColumnTemplate Object (not EditItemTemplate because i don't want to edit the row data only select rows)
4) hooking the event with a the correspondent sub in the aspx page
The grid is not ajaxfied in any way, is inside in an updatepanel,
everything looks fine, everithing compiles shows as i want when click the check a postback is launched but ... the event never is captured in the webpage until group/ungroup, next/back, or another button is pressed (the post is realized becuase every correspondent sub/function is executed but no event sub/function is launched) any suggestions i'm really tired to firegure out what's happening
in the forums there are tons of checkbox problems but the code is made in design mode not in execution time
i'm in the point that :
1) implemented the template using ITemplate interface in a custom made class
2) Inside i declared a Checkbox with Autopostback=true
3) captured the event raised by the check box internally in the class and realuching if was generated by the class itself
5) Used The template in ItemTemplate property in the GridColumnTemplate Object (not EditItemTemplate because i don't want to edit the row data only select rows)
4) hooking the event with a the correspondent sub in the aspx page
The grid is not ajaxfied in any way, is inside in an updatepanel,
everything looks fine, everithing compiles shows as i want when click the check a postback is launched but ... the event never is captured in the webpage until group/ungroup, next/back, or another button is pressed (the post is realized becuase every correspondent sub/function is executed but no event sub/function is launched) any suggestions i'm really tired to firegure out what's happening
0
Hi Rafaga2k,
Could you please post the code used for creating the custom template and adding the checkbox control into it and the code which is used for creating the RadGrid and adding the custom template into the GridTemplateColumn's ItemTemplate. Additionally please note that the custom template needs to be assigned to the ItemTemplate into the Page_Init event like is showed in the following online documentation article:
http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html#Creating_template_columns_programmatically
Looking forward for your reply.
All the best,
Radoslav
the Telerik team
Could you please post the code used for creating the custom template and adding the checkbox control into it and the code which is used for creating the RadGrid and adding the custom template into the GridTemplateColumn's ItemTemplate. Additionally please note that the custom template needs to be assigned to the ItemTemplate into the Page_Init event like is showed in the following online documentation article:
http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html#Creating_template_columns_programmatically
Looking forward for your reply.
All the best,
Radoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Rafaga2k
Top achievements
Rank 1
answered on 10 Dec 2010, 09:13 PM
sorry for not reply to your post before but i've solved my problem
instead of captured the event raised by the check box internally in the class and realuching if was generated by the class itself ... the thing that i did was hooking the event with each checkbox created via ItemCreated Event
This is how my itemTemplate finally looks:
this is where i hooked the event (for each checkbox rendered):
And finally the event code (my gris has two level a master and detail both with checkboxes)
and at least i have solved the main problem still a aestetical problem remains but i hope so that i can solve in at elegant and correct way
instead of captured the event raised by the check box internally in the class and realuching if was generated by the class itself ... the thing that i did was hooking the event with each checkbox created via ItemCreated Event
This is how my itemTemplate finally looks:
Imports Telerik.Web.UIImports System.Web.UI.WebControlsPublic Class grdChkTemplate Implements IBindableTemplate Protected WithEvents oChk As System.Web.UI.WebControls.CheckBox Public Event CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Public Sub New() MyBase.New() End Sub Protected Sub instanciateIn(ByVal container As Control) Implements System.Web.UI.IBindableTemplate.InstantiateIn oChk = New CheckBox() oChk.ID = "oChk" oChk.AutoPostBack = True container.Controls.Add(Me.oChk) End Sub Protected Function ExtractValues(ByVal container As Control) As System.Collections.Specialized.IOrderedDictionary Implements System.Web.UI.IBindableTemplate.ExtractValues Dim oDic As System.Collections.Specialized.OrderedDictionary oDic = New System.Collections.Specialized.OrderedDictionary() oDic.Add(oChk.ID, DirectCast(oChk.Checked, Boolean)) Return (oDic) End FunctionEnd Classthis is where i hooked the event (for each checkbox rendered):
Private Sub oGrid_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grdWithCheckboxes.ItemCreated, grdAnotherOne.ItemCreated If e.Item.ItemType = Telerik.Web.UI.GridItemType.Item Or e.Item.ItemType = Telerik.Web.UI.GridItemType.AlternatingItem Then Select Case sender.ID Case "grdWithCheckboxes" Dim oChk As CheckBox = CType(e.Item.FindControl("oChk"), CheckBox) If Not IsNothing(oChk) Then AddHandler oChk.CheckedChanged, AddressOf Me.grdWithCheckboxes_CheckChanged End If Case "grdAnotherOne" 'Another Code not related with this iusse End Select End IfEnd SubAnd finally the event code (my gris has two level a master and detail both with checkboxes)
Protected Sub grdWithCheckboxes_CheckChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim box As CheckBox = CType(sender, CheckBox) Dim item As Telerik.Web.UI.GridDataItem = CType(box.NamingContainer, Telerik.Web.UI.GridDataItem) Dim sID As String = "" Dim i As Integer Dim oSol As adquisiciones.abSolped Dim target As Hashtable = Nothing If (item.OwnerTableView.Name = "Objects") Then target = ChkSolped() sID = item.GetDataKeyValue("num_Object").ToString() Else target = ChkSolpedPos() sID = item.GetDataKeyValue("num_Object").ToString() & "_" & item.GetDataKeyValue("pos_Object").ToString() End If If box.Checked Then target(sID) = True Else target(sID) = Nothing End If If item.OwnerTableView.Name = "Objects" And box.Checked Then 'code to restore the state of my items in the grid End Ifand at least i have solved the main problem still a aestetical problem remains but i hope so that i can solve in at elegant and correct way
