Hi!
I have a radDropdownlist element inside a radGrid, I have to decide to enable/disable the radDropdownlist element base on it's selected value. I have
searched and tried the solutions from the forums. There are suggestions to place code in page_PreRender, ItemDataBound or ItemCreated events and check
e.item as GridDataItem or GridPagerItem and then findControl, but it could never find my dropdownlist control.
Any suggestions? What event should trigger the checking?
Thanks in advance!
Sharon
5 Answers, 1 is accepted
If you need to disable the RadDropDownList while the user changes the selection you could handle the client-side OnClientSelectedIndexChanged event in combination with disabling the control within the OnItemDataBound event for the edit item.
However, since the approach will depend on your scenario, can you please elaborate which edit mode you are using and paste the markup of your template column.
Regards,
Konstantin Dikov
Telerik
Hi! Mr. Dikov ,
Thank you for replying, below is my code, thanks. Sharon
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<telerik:RadGrid ID="rdGridStoreReturn" GridLines="None" AutoGenerateColumns="false" runat="server" PageSize="20"
AllowPaging="true" AllowMultiRowEdit="true"
OnBatchEditCommand="rdGridStoreReturn_BatchEditCommand"
OnItemDataBound="rdGridStoreReturn_ItemDataBound"
OnNeedDataSource="rdGridStoreReturn_NeedDataSource" Width="80%">
<MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="ReturnEntryId" EditMode="Batch">
<CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" SaveChangesText="儲存" CancelChangesText="取消" />
<BatchEditingSettings EditType="Row" OpenEditingEvent="DblClick" />
<SortExpressions>
<telerik:GridSortExpression FieldName="StoreNo, ReturnEntryId" SortOrder="Ascending" />
</SortExpressions>
<Columns>
<telerik:GridTemplateColumn HeaderText="審核狀態" DataField="FormStatusId" UniqueName="FormStatusColumn" HeaderStyle-Width="80px" ItemStyle-Width="80px">
<ItemTemplate><asp:Label ID="lblFormStatus" Text='<%# Eval("FormStatus") %>' runat="server"></asp:Label></ItemTemplate>
<EditItemTemplate>
<telerik:RadDropDownList runat="server" ID="radDDLAuthStatus" DataSourceID="DS_StatusChoice" DataTextField="ValueText" DataValueField="StatusID" Width="100px"></telerik:RadDropDownList>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
Hi! Mr. Dikov,
I later tried client-side function - OnBatchEditOpening as below, however, I kept getting:
Object doesn't support this property or method on args.set_cancel(true);
Thanks.
function OnBatchEditOpening(sender, args) {
if (args.get_columnUniqueName() == "FormStatusColumn") {
var authStatusCell = sender.get_masterTableView()._getCellByColumnUniqueNameFromTableRowElement(args.get_row(), "FormStatusColumn");
var authStatusValue = sender.get_batchEditingManager().getCellValue(authStatusCell);
if (authStatusValue == "closed") {
args.set_cancel(true);
//args.get_cell().getElementsByTagName("input")[0].disabled = true;
}
else {
args.get_cell().getElementsByTagName("input")[0].disabled = "";
}
}
}
Never mind, I have found the problem
Should be <ClientEvents OnBatchEditOpening="OnBatchEditOpening" />
Indeed, with Batch Editing you have to handle the client-side OnBatchEditOpening event for canceling the opening of that particular cell (conditionally) by calling the set_cancel method: args.set_cancel(true).
Kind Regards,
Konstantin Dikov
Telerik