Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Use Row filter in sql query
posted

Hi

I want to use the selected row filter in my sql query.

I have a Grid which is setup to use row filtering.
    e.Layout.FilterOptionsDefault.AllowRowFiltering = RowFiltering.OnServer;
    e.Layout.FilterOptionsDefault.FilterUIType = FilterUIType.FilterRow;

I want to to use this filter, when getting data from the base

  UltraWebGridAlarms_InitializeDataSource {

    string where = "";
    foreach (ColumnFilter cf in UltraWebGridAlarms.Rows.ColumnFilters) {
      if (string.IsNullOrEmpty(where)) {
        where = string.Format("{0}='{1}'", cf.Column.Key, cf.FilterConditions[0].CompareValue);
      } else {
        where = string.Format(" and {0}='{1}'", cf.Column.Key, cf.FilterConditions[0].CompareValue);
      }
    }

    UltraWebGridAlarms.DataSource = alarmController.getAlarms(where);
    UltraWebGridAlarms.DataBind();
 }

My problem is that the
  UltraWebGridAlarms.Rows.ColumnFilters
is empty in UltraWebGridAlarms_InitializeDataSource method.

In the method UltraWebGridAlarms_RowFilterApplying, I get access to the UltraWebGridAlarms.Rows.ColumnFilters.

Any suggestion to how I should apply the seleced row filter in my sql query?