Current filter:
                                You should refresh the page.
                                  • I need to set custom header filter through javascript code, and then refresh the gridview from the client side code.
                                    How to I set  a gridview's custom header view through javascript code?

                                    I am using the CustomJSProperties  which tracks column header filter that a user sets manually
                                    If I set on the filter expressions for a column will that filter expression be used as the filter when the gridview is refreshed from the client?

                                    [C#]
                                    settings.CustomJSProperties = (s, e) => { ASPxGridView grid = (ASPxGridView)s; var result = new System.Collections.Hashtable(); foreach (var col in grid.AllColumns) { var dataCol = col as GridViewDataColumn; if (dataCol != null) { result[dataCol.FieldName] = new Dictionary<string, object>() { { "sortIndex", dataCol.SortIndex }, { "sortOrder", dataCol.SortOrder }, {"filterExpression",dataCol.FilterExpression}, {"filterHeaderSettings",dataCol.SettingsHeaderFilter } }; } } e.Properties["cpColumnsProp"] = result;
                                • Nataly (DevExpress Support) 10.10.2019

                                  Hello Steve,
                                  Our MVC GridView control does not support filtering data only on the client without sending a callback request to the server. Even if you apply a filter on the client side (using the client side API), a callback will be initiated, and the CustomJSProperties event handler will be executed again. So, an updated filter expression will be saved to the dictionary.

                                  Would you please clarify why you need to pass filter expressions for each column from the server to the client in your scenario? As far as I understand, your GridView is filtered by an end user. Why do you need to perform additional operations on the client in this case?

                                  Do you want to save and restore the grid state (filtering, sorting etc.)? If so, GridView provides out-of-the-box solutions for this task. You can save a client layout using the GridSettingsBase.ClientLayout property (see GridView - How to save and restore the client layout where we discussed this task). Alternatively, set the GridViewSettings.SettingsCookies.Enabled property to True so that the grid will automatically save its layout to cookies. You can adjust saved parameters using GridViewSettings.SettingsCookies.

                                  Do these solutions meet your requirements? If not, please describe your final goal in greater detail so that I can provide you with an appropriate solution.

                                • steve frierdich 10.10.2019

                                  I wish you would just answer the questions directly and not  give a sermon unrelated making me waste another 24 hours for a replay.

                                  The question is:
                                   HOW IN JAVASCRIPT CAN ITEMS IN A gridview COLUMN's FILTER HEADER BE SELECTED AND UNSELECTED..

                                  I did not ask what happens after they are selected.

                                  I want to be able in javascript to select and unselect  items in a gridview column filter header list box  automatically .
                                  After they are selected it be nice if the operation of the gricview would be exactly like the user selected and or unslected the items.

                                  I have a list box.
                                  The list box contains the same items that a gridview column header filter contains and displays.
                                  See attached image
                                  When items in the list box are s elected I need the same operation to be performed on the gridview as if the same items were selected / unselected by the user in the column filter header.

                                  I need the grid view to be refreshed.
                                  I need the e.command in  APPLYHEADERCOLUMNFILTER in both  EndCallBackRouting.
                                  I need the CustomJSProperties  filtlerExpession object to be set accordingly.

                                  settings.CustomJSProperties = (s, e) => {
                                                  ASPxGridView grid = (ASPxGridView)s;
                                                  var result = new System.Collections.Hashtable();
                                                  foreach (var col in grid.AllColumns)
                                                  {
                                                      var dataCol = col as GridViewDataColumn;
                                                      if (dataCol != null)
                                                      {
                                                          result[dataCol.FieldName] = new Dictionary<string, object>() {
                                                              { "sortIndex", dataCol.SortIndex },
                                                              { "sortOrder", dataCol.SortOrder },
                                                              {"filterExpression",dataCol.FilterExpression},
                                                              {"filterHeaderSettings",dataCol.SettingsHeaderFilter }
                                                          };
                                                      }
                                                  }

                                  If the operation can not happen directly then I can always the refresh the gridview from the client side.
                                  If this way is performed the gridview has to know what items in the column filter header were selected and unselected via client code so the correct information will be shown in the gridview when the gridview is supplied with the viewmodel in the server..

                                  I tried using the the ApplyFilter for  the ASPxClientGridView object.
                                  But according javascript the ApplyFilter method is not defined for  the ASPxClientGridView object.

                                  So in reference to the image I thought I could use the following code to select  the item ELTON WALLER in the AssociateName column filter header.
                                  gridView.ApplyFilter("[AssociateName] = 'ELTON WALLER'")
                                  But as stated javascript  throws an exception saying ApplyFilter is not supported.

                                  I also did not see the ApplyFilter method listed as a gridView.filterhelp method.
                                  The name of the gridview object  is gridView.

                                  So after all that back to the original question.
                                  Can the items in a gridview's column filter header be selected and unselected from javascript.

                                1 Solution

                                Creation Date Importance Sort by

                                seems the ApplyFilter method is now working.

                                • Nataly (DevExpress Support) 10.11.2019

                                  Hello,
                                  Based on your initial question, it was not clear that you use an external list box to filter GridView and that you just need to apply a filter to a grid based on this list box. That is why I asked you to clarify your entire scenario to be able to suggest the most appropriate solution.

                                  Thank you for the clarification of your scenario. Now it is clear. Yes, as you correctly mentioned, the client-side ApplyFilter method allow applying filters on the client side. Let me know if you have any further questions.

                                • steve frierdich 10.11.2019

                                  Most the ticket I post are unclear.
                                  Half the time I am not sure what I am saying.

                                  Thanks for the update.