Current filter:
                                You should refresh the page.
                                  • I refer to S30339 and example E13
                                    If I change E13's code (see attachment) from
                                              <dxwgv:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="AccessDataSource1" KeyFieldName="CustomerID">
                                    to
                                              <dxwgv:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="AccessDataSource1" KeyFieldName="CustomerID">
                                              <SettingsBehavior AllowFocusedRow="True" />
                                                   <SettingsDetail AllowOnlyOneMasterRowExpanded="True" ShowDetailRow="True" />
                                    and change the Page_Load function as follows:
                                         Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
                                            ClearSelectionOnOtherPages()
                                            If grid.FocusedRowIndex = 0 Then
                                                grid.FocusedRowIndex = -1
                                            End If
                                         End Sub
                                    Despite this, when I display the page, row 0 is focused, even though grid.FocusedRowIndex already has a value of -1, as suggested in S30339
                                    I can click on the "+" button for a row and the detailrow is displayed, even though the focusedrow is a different row. I have tried various ideas to set the focus of the row where the detailedrow is displayed, without success. Please tell me how I can do this.
                                    Please tell me how I can disable the focusedrow until a row is actually selected, if at all possible.
                                    Finally, if I want to select and set the focus of a row that isn't on the first page, how do I do this? For example, in Northwind Traders the opening page of the Sales Order table is usually in the range 10248-10257. I would like to be able to open the AspxGridView and go directly to, say, SalesOrder #11015, which is on page 77 in my data.
                                    How can I go there and set the selected row and the focused row to this value? I can do it by setting a filter and getting just the single row, but when I clear the filter the focus is lost and it reverts back to the first record. It's just too easy to get lost in a gazillion records this way.
                                    Any suggestions will be gratefully accepted. I think ASPxGridView is awesome, and thanks once again for all the help you guys have provided.

                                Show all comments
                                • Ivan Nik (DevExpress) 09.21.2009

                                  Hi Donn,
                                  To remove focus, you need to use SetFocusedRowIndex Client-Side Method. I've attached a sample project that demonstrates how you can set focus to a detail row, which gets expanded, or remove focus otherwise. You can set selection for the grid on any page using the key value of the row using ASPxGridView.Selection.SelectRowByKey Method. The FocusedRow property reflects grid's representative state - an element can't be focused if it's not displayed (e.g. it's on another page). So this behavior is by design.
                                  With best regards,
                                  Ivan N.

                                • Donn Edwards 09.21.2009

                                  Thanks once again. I will use the example provided. You guys are amazing.

                                • Donn Edwards 09.21.2009

                                  Thanks

                                • Donn Edwards 09.25.2009

                                  Thanks for the sample code but I had to modify it a bit, as per attached version.
                                  Now can you please help me with selecting data, if this is at all possible.
                                  I have created
                                      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                                          grid.Selection.UnselectAll()
                                          grid.Selection.SetSelectionByKey(27, True)
                                      End Sub
                                  This selects a row on page 2. I have looked everywhere but I can't figure out how to find the page number of the selected row, and then how to select that page programatically.
                                  Are there methods to do this?
                                  Thanks in advance once again.

                                • Ivan Nik (DevExpress) 09.28.2009

                                  Hi Donn,
                                  You can use the ASPxGridView.FindVisibleIndexByKeyValue Method for this purpose. The example from this help article shows how to navigate to a page that contains a row with the given key value. You can use the same approach for selection.
                                  With best regards,
                                  Ivan N.

                                • Donn Edwards 09.28.2009

                                  Thanks once again.
                                  I have converted the C# example to VB.NET using a code translator, and will fiddle with it until it works.
                                      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
                                          ' Obtain the visible index of the required row.
                                          Dim rowIndex As Integer = grid.FindVisibleIndexByKeyValue("OLDWO")
                                          If (rowIndex < 0) Then
                                              Return
                                          End If
                                          If Not IsRowVisibleOnScreen(rowIndex) Then
                                              ' Switch to the page which contains the required row.
                                              GoToPage(rowIndex)
                                          End If
                                          ' Focus the required row.
                                          grid.FocusedRowIndex = rowIndex
                                      End Sub

                                      Private Function IsRowVisibleOnScreen(ByVal rowIndex As Integer) As Boolean
                                          Dim startIndex As Integer = (grid.PageIndex * grid.SettingsPager.PageSize)
                                          Dim endIndex As Integer = (startIndex + grid.SettingsPager.PageSize)
                                          Return ((rowIndex >= startIndex) _
                                                      AndAlso (rowIndex < endIndex))
                                      End Function

                                      Private Sub GoToPage(ByVal rowIndex As Integer)
                                          grid.PageIndex = (rowIndex / grid.SettingsPager.PageSize)
                                      End Sub

                                • Ivan Nik (DevExpress) 09.29.2009

                                  Hi Donn,
                                  If you experience any problems, don't hesitate to contact us at any moment.
                                  With best regards,
                                  Ivan N.

                                • Donn Edwards 10.02.2009

                                  This is exactly what I was looking for. Thanks once again.

                                0 Solutions

                                Creation Date Importance Sort by