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

How to disabled Raddropdownlist

5 Answers 339 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sharon
Top achievements
Rank 1
sharon asked on 13 Jan 2016, 09:55 AM

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

Sort by
0
Konstantin Dikov
Telerik team
answered on 14 Jan 2016, 02:04 PM
Hello Sharon,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
sharon
Top achievements
Rank 1
answered on 15 Jan 2016, 05:40 AM

 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>

0
sharon
Top achievements
Rank 1
answered on 15 Jan 2016, 08:35 AM

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 = "";
                }
            }
        }

0
sharon
Top achievements
Rank 1
answered on 15 Jan 2016, 09:28 AM

Never mind, I have found the problem

Should be <ClientEvents OnBatchEditOpening="OnBatchEditOpening" />

0
Konstantin Dikov
Telerik team
answered on 15 Jan 2016, 02:04 PM
Hello Sharon,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
sharon
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
sharon
Top achievements
Rank 1
Share this question
or