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

radgrid inline edit mode

2 Answers 326 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AName
Top achievements
Rank 1
AName asked on 20 Dec 2013, 07:18 PM

Hi there,


I have a RadGrid that displays a description radtextbox,  and a percentage a radnumerictextbox

I want the user to be able to edit only existing rows by way of the inline.



This currently works with two exceptions.

1. Both textboxes appear blank when edit is clicked.

2. I need a way to perform validation against these boxes, to make sure they are not blank etc.





My aspx is as follows...



<telerik:RadGrid OnItemEvent="rgMyGrid_ItemEvent" ID="rgMyGrid" Width="100%" AllowPaging="True" PageSize="8" runat="server" AllowSorting="True" GridLines="None"
    AutoGenerateColumns="True" ShowStatusBar="True" CellSpacing="0" EnableViewState="false" AutoGenerateEditColumn="true" OnUpdateCommand="rgMyGrid_UpdateCommand">
    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
    <MasterTableView ShowFooter="false" DataKeyNames="TaxID" EditMode="InPlace" Width="100%" CommandItemDisplay="Bottom"  HorizontalAlign="NotSet" AutoGenerateColumns="false">
    <CommandItemTemplate>
        <div style="padding: 5px 5px; text-align:left;">
            <asp:LinkButton ID="reloadTaxes" Text="Reset to Defaults" CommandName="Reload" runat="server" OnCommand="lbReload_Command"></asp:LinkButton>
        </div>
    </CommandItemTemplate>
    <Columns>
        <telerik:GridBoundColumn DataField="TaxID" HeaderText="TaxID" UniqueName="TaxID" SortExpression="TaxID" Visible="false"></telerik:GridBoundColumn>
        <telerik:GridTemplateColumn DataField="TaxDescription" UniqueName="TaxDescription" HeaderText="TaxDescription" SortExpression="TaxDescription" HeaderStyle-Width="128px" ItemStyle-Width="128px" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left">
            <ItemTemplate>
                <%#DataBinder.Eval(Container.DataItem, "TaxDescription")%>
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadTextBox Width="128px" runat="server" ID="rgMyGrid_Description" MaxLength="20"></telerik:RadTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn DataField="TaxRate" UniqueName="TaxRate" HeaderText="TaxRate" SortExpression="TaxRate"  ItemStyle-Width="56px"  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left">
            <ItemTemplate>
                <%#DataBinder.Eval(Container.DataItem, "TaxRate")%>
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox Width="56px" ID="rgMyGrid_Amount" Type="Percent" MinValue="0" MaxValue="100" MaxLength="2" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="," Culture="en-US"  runat="server">
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>
    </MasterTableView>
    <ClientSettings></ClientSettings>
    <FilterMenu EnableTheming="True">
        <CollapseAnimation Duration="200" Type="OutQuint"></CollapseAnimation>
    </FilterMenu>
</telerik:RadGrid>


Any suggestions would be a big help.



thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 21 Dec 2013, 05:08 AM
Hi,

I guess you want to display the description and percentage values in edit mode,please try the following code snippet. You can use RequiredFieldValidator to perform validation.

ASPX:
<telerik:GridTemplateColumn DataField="TaxDescription" UniqueName="TaxDescription" HeaderText="TaxDescription"
        SortExpression="TaxDescription" HeaderStyle-Width="128px" ItemStyle-Width="128px"
        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left">
        <ItemTemplate>
            <%#DataBinder.Eval(Container.DataItem, "TaxDescription")%>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadTextBox Width="128px" runat="server" ID="rgMyGrid_Description" MaxLength="20"
                Text='<%#Eval("TaxDescription") %>'>
            </telerik:RadTextBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn DataField="TaxRate" UniqueName="TaxRate" HeaderText="TaxRate"
        SortExpression="TaxRate" ItemStyle-Width="56px" HeaderStyle-HorizontalAlign="Center"
        ItemStyle-HorizontalAlign="Left">
        <ItemTemplate>
            <%#DataBinder.Eval(Container.DataItem, "TaxRate")%>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadNumericTextBox Width="56px" ID="rgMyGrid_Amount" Type="Percent" MinValue="0"
                MaxValue="100" MaxLength="2" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator=","
                Culture="en-US" runat="server" DbValue='<%#Eval("TaxRate") %>'>
            </telerik:RadNumericTextBox>
            <asp:RequiredFieldValidator runat="server" ID="rfvDesc" ErrorMessage="*" ControlToValidate="rgMyGrid_Amount"></asp:RequiredFieldValidator>
        </EditItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy
0
AName
Top achievements
Rank 1
answered on 23 Dec 2013, 03:47 PM
Thank you this worked great.
Tags
Grid
Asked by
AName
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
AName
Top achievements
Rank 1
Share this question
or