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

Tab Order in Grid

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas Derenthal
Top achievements
Rank 1
Thomas Derenthal asked on 14 Nov 2014, 07:46 PM
I have one textbox and a check box in a grid. In the TextChanged server event I have some code that executes. When done with that code I need the cursor to go to the next textbox. As it is, it goes back to the textbox for the first record in the grid. Is it possible to make the cursor go to the textbox in the next record when tab or enter is pressed? The textbox is Amount Approved. 

<telerik:RadGrid ID="gridFundingBills" runat="server" Width="1110px" AllowMultiRowSelection="True"
                AutoGenerateColumns="False"
                OnNeedDataSource="gridFundingBills_NeedDataSource"
                OnItemDataBound="gridFundingBills_ItemDataBound"
                OnItemCreated="gridFundingBills_ItemCreated"
                SelectedItemStyle-CssClass="selectedrow"
                GridLines="None" >
                <MasterTableView DataKeyNames="FundingDtlID,SourceBankAcctID,RemainingAmt" EditMode="InPlace" Width="1090px"
                    NoMasterRecordsText="There are no open funding bills at this time">
                    <Columns>
                        <telerik:GridBoundColumn DataField="CustomerNm" FilterControlAltText="Filter CustomerNm column" HeaderText="Property" SortExpression="CustomerNm" UniqueName="CustomerNm" ItemStyle-Width="100px" HeaderStyle-Width="125px" HeaderStyle-HorizontalAlign="Left">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="VendorNm" FilterControlAltText="Filter VendorNm column" HeaderText="Vendor" SortExpression="VendorNm" UniqueName="VendorNm" ItemStyle-Width="150px" HeaderStyle-Width="150px" HeaderStyle-HorizontalAlign="Left">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="BankAcct" FilterControlAltText="Filter BankAcct column" HeaderText="Bank" ReadOnly="True" SortExpression="BankAcct" UniqueName="BankAcct" ItemStyle-Width="125px" HeaderStyle-Width="125px" HeaderStyle-HorizontalAlign="Left">
                        </telerik:GridBoundColumn>
                        <telerik:GridHyperLinkColumn UniqueName="BillNo" HeaderText="Bill Reference #" DataTextField="BillNo" DataNavigateUrlFields="BillUrl" DataNavigateUrlFormatString="http://{0}" Target="_blank" ItemStyle-Width="175px" HeaderStyle-Width="150px">
                        </telerik:GridHyperLinkColumn>
                        <telerik:GridBoundColumn DataField="BillURL" FilterControlAltText="Filter BillURL column" ReadOnly="True" SortExpression="BillURL" UniqueName="BillURL" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="BillPeriod" FilterControlAltText="Filter BillPeriod column" HeaderText="Bill Period" ReadOnly="True" SortExpression="BillPeriod" UniqueName="BillPeriod" ItemStyle-Width="125px" HeaderStyle-Width="125px" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="DueDt" DataType="System.DateTime" FilterControlAltText="Filter DueDt column" HeaderText="Due Date" SortExpression="DueDt" UniqueName="DueDt" DataFormatString="{0:d}" ItemStyle-Width="75px" HeaderStyle-Width="75px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="TotalAmt" DataType="System.Decimal" FilterControlAltText="Filter TotalAmt column" HeaderText="TotalAmt" SortExpression="Total Due" UniqueName="TotalAmt" DataFormatString="{0:F}" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="50px" HeaderStyle-Width="60px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="RemainingAmt" DataType="System.Decimal" FilterControlAltText="Filter RemainingAmt column" HeaderText="Remaining Balance" ReadOnly="True" SortExpression="RemainingAmt" UniqueName="RemainingAmt" DataFormatString="{0:F}" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="50px" HeaderStyle-Width="60px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="FundingDtlID" DataType="System.Guid" FilterControlAltText="Filter FundingDtlID column" HeaderText="FundingDtlID" ReadOnly="True" SortExpression="FundingDtlID" UniqueName="FundingDtlID" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="SourceBankAcctID" DataType="System.Guid" FilterControlAltText="Filter BankAcctID column" HeaderText="BankAcctID" ReadOnly="True" SortExpression="BankAcctID" UniqueName="BankAcctID" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn HeaderText="Amount Approved" UniqueName="AmtApproved" HeaderStyle-Width="70px"
                            ItemStyle-Width="70px" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                            <ItemTemplate>
                                <asp:TextBox ID="AmountApproved" runat="server" Width="55px" OnTextChanged="AmountApproved_TextChanged"
                                    AutoPostBack="true" CssClass="numericAlign"></asp:TextBox>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="50px" ItemStyle-Width="50px">
                        </telerik:GridClientSelectColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="300px"></Scrolling>
                    <ClientEvents OnRowSelected="handleTextBoxValue" OnRowDeselected="handleTextBoxValue" OnActiveRowChanged="sumAmtApproved" />
                    <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
                    
                </ClientSettings>
            </telerik:RadGrid>

 protected void AmountApproved_TextChanged(object sender, EventArgs e)
    {
        //code to update values, 
        UpdateBalances();
        //need to tab to AmountApproved in next record
    }

2 Answers, 1 is accepted

Sort by
0
Thomas Derenthal
Top achievements
Rank 1
answered on 15 Nov 2014, 12:46 PM
I should qualify this by pointing out that my code does a loop to sum up some values. If I use this, item.FindControl("AmountApproved").Focus(), then the focus will be on the textbox in the last record. Is there a way to determine the record index of the current record before the sum loop starts and then increment the index by one and set the focus on the next record?
0
Konstantin Dikov
Telerik team
answered on 19 Nov 2014, 10:09 AM
Hi Thomas,

You should use the TextBox control and its NamingContainer to find the corresponding GridDataItem. Once you have reference to the current GridDataItem you can use its index to find the next one. When you have reference to the next GridDataItem you can find the TextBox control and call its Focus() method.

For detailed information for accessing controls in RadGrid you can take a look at the following help article:
Hope this helps.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Thomas Derenthal
Top achievements
Rank 1
Answers by
Thomas Derenthal
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or