This is a migrated thread and some comments may be shown as answers.

Visibility of RadDatePicker in other column

2 Answers 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 29 Aug 2013, 04:02 PM
Hi there,

Been looking around lately... couldn't find a way to do it clean.
I have the insert row in mode "InPlace" and one column has a checkbox and other column has a datepicker:
<telerik:GridTemplateColumn DataField="IN_RESLN" HeaderText="RĂ©solu" UniqueName="IN_RESLN" SortExpression="IN_RESLN"
FilterControlWidth="100px" HeaderStyle-Width="120px">
    <ItemTemplate>
        <asp:CheckBox ID="CheckResolution" runat="server" Checked='<%#If(Eval("IN_RESLN") = "True", True, False)%>' Enabled="false" />
    </ItemTemplate>
    <InsertItemTemplate>
        <asp:CheckBox ID="InsertCheckResolution" runat="server" AutoPostBack="True" />
    </InsertItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="DA_RESLN" HeaderText="Date de résolution" UniqueName="DA_RESLN" SortExpression="DA_RESLN"
ShowFilterIcon="true" HeaderStyle-Width="120px" FilterControlWidth="100px"
AutoPostBackOnFilter="true" FilterDelay="2000" CurrentFilterFunction="Contains">
    <ItemTemplate>
        <asp:Label ID="LabelDateResolution" Text='<%#Eval("DA_RESLN", "{0:yyyy-MM-dd}")%>' runat="server"></asp:Label>
    </ItemTemplate>
    <FilterTemplate>
        <telerik:RadDatePicker runat="server" ID="DatePickerDateResolution"></telerik:RadDatePicker>
    </FilterTemplate>
    <EditItemTemplate>
        <telerik:RadDatePicker runat="server" ID="DatePickerDateResolution"></telerik:RadDatePicker>
    </EditItemTemplate>
    <InsertItemTemplate>
        <telerik:RadDatePicker runat="server" ID="DatePickerDateResolution"></telerik:RadDatePicker>
        <asp:CustomValidator ID="DatePickerDateResolution_Validator" runat="server" ErrorMessage="*" ControlToValidate="DatePickerDateResolution" OnServerValidate="DatePickerDateResolution_Validator_ServerValidate"></asp:CustomValidator>
    </InsertItemTemplate>
</telerik:GridTemplateColumn>


I have Registered the ItemCreated event and got something like this:

If TypeOf e.Item Is GridDataInsertItem Then
            Dim chkResln As CheckBox = DirectCast(insertItem("IN_RESLN").FindControl("InsertCheckResolution"), CheckBox)
            Dim dtePickerDaResln As RadDatePicker = DirectCast(insertItem("DA_RESLN").FindControl("DatePickerDateResolution"), RadDatePicker)
            Dim dtePickerDaReslnValidator As CustomValidator = DirectCast(insertItem("DA_RESLN").FindControl("DatePickerDateResolution_Validator"), CustomValidator)
 
            dtePickerDaResln.Visible = chkResln.Checked
            dtePickerDaReslnValidator.Visible = chkResln.Checked
End If


So actually trying to setup the visibility of the datepicker in other column if the checkbox is checked.
At first when itemcreated is hit, the datepicker is not visible since of course, the checkbox is unchecked.
But once i click it to check it, partial postback comes, and it's still considered unchecked. But it's checked in the interface!

So wondering if you guys can hint me up? is there something i could do to make it work server side?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 30 Aug 2013, 04:07 AM
Hi Nicolas,

Please try the following code snippet to hide the RadDatePicker on checkbox unchecked.

VB:
Protected Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataInsertItem Then
        Dim insertItem As GridDataInsertItem = DirectCast(e.Item, GridDataInsertItem)
        Dim chkResln As CheckBox = DirectCast(insertItem.FindControl("InsertCheckResolution"), CheckBox)
        Dim dtePickerDaResln As RadDatePicker = DirectCast(insertItem.FindControl("DatePickerDateResolution"), RadDatePicker)
        chkResln.CheckedChanged += New EventHandler(AddressOf chkResln_CheckedChanged)
        If chkResln.Checked Then
            dtePickerDaResln.Visible = True
        Else
            dtePickerDaResln.Visible = False
        End If
    End If
End Sub
 
Private Sub chkResln_CheckedChanged(sender As Object, e As System.EventArgs)
    Dim chk As CheckBox = DirectCast(sender, CheckBox)
    Dim item As GridDataInsertItem = DirectCast(chk.NamingContainer, GridDataInsertItem)
    Dim dtePickerDaResln As RadDatePicker = DirectCast(item.FindControl("DatePickerDateResolution"), RadDatePicker)
    If chk.Checked Then
        dtePickerDaResln.Visible = True
    Else
        dtePickerDaResln.Visible = False
    End If
End Sub

Thanks,
Princy
0
Nicolas
Top achievements
Rank 1
answered on 30 Aug 2013, 04:40 PM
Thanks a lot it worked perfectly, exept you have to use AddHandler and not +=
Tags
Grid
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Nicolas
Top achievements
Rank 1
Share this question
or