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

GridDateTimeColumn Invalid Date

1 Answer 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexandru
Top achievements
Rank 1
Alexandru asked on 30 Jun 2015, 06:31 PM

I have the following Grid. The problem is I can not add a RequiredFieldValidator for the GridDateTimeColumn in edit mode, as I did for the other columns. I would like to know if it is possible, in the code behind C#, to disable the insert button (the tick sign) when the date is not valid or if I can add a validator for the date, that would not allow to insert an item if the corresponding date is not valid. I have also attached a picture. 

 Thank you very much for any idea, Alexandru Popa.

<telerik:RadGrid ID="rgMealPlanPrices" runat="server" AutoGenerateColumns="false"
                                AllowFilteringByColumn="False" AllowSorting="True" AllowPaging="True" PageSize="30"
                                OnNeedDataSource="rgMealPlanPrices_NeedDataSource"
                                OnDeleteCommand="rgMealPlanPrices_DeleteCommand"
                                OnItemDataBound="rgMealPlanPrices_ItemDataBound"
                                OnInsertCommand="rgMealPlanPrices_InsertCommand"
                                OnItemCommand="rgMealPlanPrices_ItemCommand"
                                OnItemCreated="rgMealPlanPrices_ItemCreated">
                                <MasterTableView DataKeyNames="Id" CommandItemDisplay="TopAndBottom" ShowHeadersWhenNoRecords="True"
                                    TableLayout="Fixed" EditMode="InPlace" meta:resourcekey="rgMealPlanPricesResource">
                                    <CommandItemSettings AddNewRecordText="Adauga" ShowRefreshButton="False" ExportToPdfText="Export to PDF" />
                                    <RowIndicatorColumn Visible="False">
                                        <HeaderStyle Width="20px"></HeaderStyle>
                                    </RowIndicatorColumn>
                                    <ExpandCollapseColumn Visible="False">
                                        <HeaderStyle Width="19px"></HeaderStyle>
                                    </ExpandCollapseColumn>
 
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" HeaderStyle-Width="30px">
                                        </telerik:GridEditCommandColumn>
 
                                        <telerik:GridBoundColumn DataField="Id" HeaderText="Id" ReadOnly="true" UniqueName="Id"
                                            ForceExtractValue="Always" ConvertEmptyStringToNull="true" Display="False" />
                                        <telerik:GridBoundColumn DataField="Code" HeaderText="Cod" meta:resourcekey="MealPlanCodeResource" Display="False" UniqueName="MealPlanCode">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn DataField="MealPlan" HeaderText="Regim de masa" UniqueName="MealPlanName" meta:resourcekey="MealPlanResource">
                                            <EditItemTemplate>
                                                <telerik:RadComboBox ID="rcbMealPlan" runat="server" AppendDataBoundItems="True"
                                                    DataTextField="DisplayName" DataValueField="Id" Filter="Contains" MarkFirstMatch="true"
                                                    DropDownWidth="240" EmptyMessage="Search by name" meta:resourcekey="rcbMealPlanResource" Width="240">
                                                </telerik:RadComboBox>
                                                <asp:RequiredFieldValidator ID="rfvMealPlan" runat="server" ControlToValidate="rcbMealPlan" EnableClientScript="true" SetFocusOnError="true"
                                                    meta:resourcekey="rfvMealPlanResource"
                                                </asp:RequiredFieldValidator>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <%# Eval("DisplayName") %>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="MealPlanPrice" HeaderText="Pret" UniqueName="MealPlanName" meta:resourcekey="MealPlanPriceResource">
                                            <EditItemTemplate>
                                                <telerik:RadNumericTextBox ID="txtPrice" runat="server" DataType="System.Decimal" Width="50px">
                                                    <NumberFormat DecimalDigits="2" DecimalSeparator="." GroupSeparator="" KeepNotRoundedValue="true" AllowRounding="false" />
                                                </telerik:RadNumericTextBox>
                                                <asp:RequiredFieldValidator ID="rfvPrice" runat="server" ControlToValidate="txtPrice" EnableClientScript="true" SetFocusOnError="true"
                                                    meta:resourcekey="rfvMealPlanResource" />
 
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <%# Eval("Price") %>
                                            </ItemTemplate>
                                            <HeaderStyle Width="80px" />
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="MealPlanCalories" HeaderText="Calorii" UniqueName="MealPlanCalories" meta:resourcekey="MealPlanCaloriesResource">
                                            <EditItemTemplate>
                                                <telerik:RadNumericTextBox ID="txtCalories" runat="server" DataType="System.Decimal" Width="50px">
                                                    <NumberFormat DecimalDigits="0" DecimalSeparator="." GroupSeparator="" KeepNotRoundedValue="true" AllowRounding="false" />
                                                </telerik:RadNumericTextBox>
                                                <asp:RequiredFieldValidator ID="rfvCalories" runat="server" ControlToValidate="txtCalories" EnableClientScript="true" SetFocusOnError="true"
                                                    meta:resourcekey="rfvMealPlanResource" />
 
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <%# Eval("Calories") %>
                                            </ItemTemplate>
                                            <HeaderStyle Width="180px" />
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="MealPlanConfortSporit" HeaderText="ConfortSporit" UniqueName="MealPlanConfortSporit">
                                            <EditItemTemplate>
                                                <asp:CheckBox ID="ckbConfortSporit" runat="server" ></asp:CheckBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <%# Eval("ConfortSporit") %>
                                            </ItemTemplate>
                                            <HeaderStyle Width="180px" />
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridDateTimeColumn DataField="IssueDate" HeaderText="Valid de la" HeaderStyle-Wrap="true" DataFormatString="{0:dd.MM.yyyy}"
                                            meta:resourcekey="ValidFromResource" PickerType="DatePicker" Resizable="true">
                                            <HeaderStyle Width="80px" />
                                        </telerik:GridDateTimeColumn>
                                        <telerik:GridButtonColumn ConfirmText="Delete this meal plan?" ConfirmDialogType="RadWindow" ConfirmDialogHeight="110px"
                                            ConfirmTitle="Delete" ButtonType="ImageButton" Text="Delete" CommandName="Delete" meta:resourcekey="DeleteCommandResource"
                                            ImageUrl="~\Image\icon\16x16_Microsoft_Style\delete_16_OLD.gif" UniqueName="DeleteServiceColumn">
                                            <HeaderStyle Width="40px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
 
                                </MasterTableView>
                            </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 03 Jul 2015, 09:55 AM
Hi Alexandru,

I would recommend you to examine the following help article which elaborates more on adding a RequireFieldValidator to the built-in column.

Regards,
Kostadin
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
Alexandru
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or