Hi,
I'm pretty new to the Telerik controls and also have very little experience with javascript. Here is my problem:
I have a RadGrid that displays some information from a database and allows the user to modify this data by clicking an Edit link button and then using a form template.
I have a client side row double click function that puts the row into edit mode that I found on one of the Telerik support documents, but I need to disable this for specific rows based on the enabled status of the link button.
Code.
I've cut out a lot of the columns of the grid and also the form template as they are not relevant. I've highlighted the relevant parts in bold.
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function RowDblClick(sender, eventargs)
{
sender.get_masterTableView().editItem(eventargs.get_itemIndexHierarchical());
}
</script>
</telerik:RadCodeBlock>
<telerik:RadGrid ID="ShiftRadGrid" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="ShiftSqlDataSource"
ShowFooter="True" GridLines="Both">
<ExportSettings ExportOnlyData="True" OpenInNewWindow="True">
</ExportSettings>
<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<ClientEvents OnRowDblClick="RowDblClick" />
</ClientSettings>
<MasterTableView DataSourceID="ShiftSqlDataSource" DataKeyNames="id">
<Columns>
<telerik:GridEditCommandColumn buttontype="LinkButton" UniqueName="RadGrdEditCommand" EditText="Edit">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn CommandName="Select" FilterControlAltText="Filter Select column" Text="Select" UniqueName="Select">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="ScheduleDate" DataFormatString="{0:d}" DataType="System.DateTime" FilterControlAltText="Filter ScheduleDate column" HeaderText="Date Worked" SortExpression="ScheduleDate" UniqueName="ScheduleDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CAName" FilterControlAltText="Filter CAName column" HeaderText="Name" ReadOnly="True" SortExpression="CAName" UniqueName="CAName">
<ItemStyle Wrap="False" />
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings EditFormType ="Template">
<FormTemplate>
<table id="FormTable" class="Table4" border="0">
<tr>
<td>
<asp:Label ID="lblWorkingDate" runat="server" Text ="Working Date:"></asp:Label>
</td>
<td>
<telerik:RadDatePicker ID="RadShiftEditWorkingDatePicker" runat="server"
Height="22px" Width="100px"
DBSelectedDate='<%# Bind("ScheduleDate", "{0:d}")%>' >
</telerik:RadDatePicker>
</td>
<td>
<asp:Label ID="lblHospital" runat="server" Text="Hospital"></asp:Label>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
Protected Sub ShiftRadGrid_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles ShiftRadGrid.ItemDataBound
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim itemCounter As Integer = item.Cells.Count
Try
'Dim lnkEdit As LinkButton = DirectCast(e.Item.FindControl("RadGrdEditCommand"), LinkButton)
Dim lnkEdit As LinkButton = DirectCast(item("RadGrdEditCommand").Controls(0), LinkButton)
lnkEdit.Enabled = False
' I've disabled all rows just to test but this will ultimately be based on logic.
Catch ex As Exception
' Rest of logic.
End try
end if
End Sub
Hope this is clear enough. Many thanks.
I'm pretty new to the Telerik controls and also have very little experience with javascript. Here is my problem:
I have a RadGrid that displays some information from a database and allows the user to modify this data by clicking an Edit link button and then using a form template.
I have a client side row double click function that puts the row into edit mode that I found on one of the Telerik support documents, but I need to disable this for specific rows based on the enabled status of the link button.
Code.
I've cut out a lot of the columns of the grid and also the form template as they are not relevant. I've highlighted the relevant parts in bold.
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function RowDblClick(sender, eventargs)
{
sender.get_masterTableView().editItem(eventargs.get_itemIndexHierarchical());
}
</script>
</telerik:RadCodeBlock>
<telerik:RadGrid ID="ShiftRadGrid" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="ShiftSqlDataSource"
ShowFooter="True" GridLines="Both">
<ExportSettings ExportOnlyData="True" OpenInNewWindow="True">
</ExportSettings>
<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<ClientEvents OnRowDblClick="RowDblClick" />
</ClientSettings>
<MasterTableView DataSourceID="ShiftSqlDataSource" DataKeyNames="id">
<Columns>
<telerik:GridEditCommandColumn buttontype="LinkButton" UniqueName="RadGrdEditCommand" EditText="Edit">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn CommandName="Select" FilterControlAltText="Filter Select column" Text="Select" UniqueName="Select">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="ScheduleDate" DataFormatString="{0:d}" DataType="System.DateTime" FilterControlAltText="Filter ScheduleDate column" HeaderText="Date Worked" SortExpression="ScheduleDate" UniqueName="ScheduleDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CAName" FilterControlAltText="Filter CAName column" HeaderText="Name" ReadOnly="True" SortExpression="CAName" UniqueName="CAName">
<ItemStyle Wrap="False" />
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings EditFormType ="Template">
<FormTemplate>
<table id="FormTable" class="Table4" border="0">
<tr>
<td>
<asp:Label ID="lblWorkingDate" runat="server" Text ="Working Date:"></asp:Label>
</td>
<td>
<telerik:RadDatePicker ID="RadShiftEditWorkingDatePicker" runat="server"
Height="22px" Width="100px"
DBSelectedDate='<%# Bind("ScheduleDate", "{0:d}")%>' >
</telerik:RadDatePicker>
</td>
<td>
<asp:Label ID="lblHospital" runat="server" Text="Hospital"></asp:Label>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
Protected Sub ShiftRadGrid_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles ShiftRadGrid.ItemDataBound
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim itemCounter As Integer = item.Cells.Count
Try
'Dim lnkEdit As LinkButton = DirectCast(e.Item.FindControl("RadGrdEditCommand"), LinkButton)
Dim lnkEdit As LinkButton = DirectCast(item("RadGrdEditCommand").Controls(0), LinkButton)
lnkEdit.Enabled = False
' I've disabled all rows just to test but this will ultimately be based on logic.
Catch ex As Exception
' Rest of logic.
End try
end if
End Sub
Hope this is clear enough. Many thanks.