Forum Discussion

David91's avatar
David91
Frequent Contributor
9 years ago

Search multiple lines (rows)

I need from that object UltraGrid (Infragistics.Win.UltraWinGrid.UltraGrid) find all the rows that have a value in the second column "1". I used method FindRow, for example: var r = ultraGrid.FindRow(2, "1"); but this method search only first row with value "1". I need search all rows with value "1" i second column and click on row. For example. Line searches and clicks on it ..etc. Please advice how to retrieve all rows with a value "1" in the second column...Thank you so much for advice.. :)

 

 

3 Replies

    • David91's avatar
      David91
      Frequent Contributor
      Yes, I tried this. Writes me an error in this line of Table = Grid.DataSource.Tables.Item (0); ... DataSource.Tables is null or not object.. :(.
       
      My edit code:
       
      function Main3 ()
      {
      var p, Grid, Table, RowId, ColumnName, Value;


      Grid = ShellForm.MainWorkspace.BookWorkingMainView.m_tableLayoutPanelMain.m_panelLeft.LeftWorkspace.TableLayoutDynamicView.m_tableLayoutPanel.BoundedDynamicViewPanel.UltraGridViewControl.m_ultraGrid;

      Table = Grid.DataSource.Tables.Item(0);

      // Locate row by cell value
      ColumnName = 2;
      Value = "1";
      RowId = FindRow (Table, ColumnName, Value);
      if (RowId >= 0)
      Log.Message ("Index of the found data table row: " + RowId);
      else
      Log.Error ("The '" + ColumnName + "' column of the data table does not contain the value of '" + Value + "'.");
      }

      function FindRow (Table, ColumnName, Value)
      {
      var View = Table.DefaultView;
      View.Sort = ColumnName;
      return View.Find (Value);
      }
      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        Sounds like that's simply how the "find" method works for this control. It finds the first one, then stops.

         

        Unless it has a "FindAll" method (or similar), then you'll need to get a row count and run loop to check that value in each row one by one.

         

        In fact, the help page linked to by Ravik pretty much says this. From that help page:

         

        "The UltraGrid control does not have built-in methods for searching within the grid, so you will need to implement the search algorithm yourself. A general search approach implies that you iterate through the grid data views rows and on each iteration check whether the row meets the specified condition."