none
Filtering in JSGrid control RRS feed

  • Question

  • I’ve been trying to add a filtering feature on the JSGrid control for a few days, but there is so little documentation on it (especially for the client side) that I can hardly figure out how it works.

    I have the following JavaScript code, but I have no idea how to implement the delegates methods. Moreover, the following code doesn’t work and returns an error.

    If you have any idea, or any documentation on this, please share!

    Type.registerNamespace("GridManager");
    
    GridManager = function () {
    
    …
    
     
    
           this.Init = function (jsGridControl, initialData, props) {
    
                  this.JSGridControl = jsGridControl;
    
                  this.Properties = props;
    
     
    
                  // Initialise the delegates (sorting, filtering, etc).
    
                  this.InitDelegates();
    
     
    
                  // get the initial data.
    
                  var args = Sys.Serialization.JavaScriptSerializer.serialize({
    
                         Command: commands.GetData,
    
                         DisplayMode: GM.Properties.displayMode
    
                  });
    
     
    
                  // Client calls the display callback.
    
                  eval(callbacks.displayCallback);
    
     
    
           }
    
           this.InitDelegates = function () {
    
                  // Delegates to handle filtering.
    
                  this.JSGridControl.SetDelegate(SP.JsGrid.DelegateType.LaunchFilterDialog, HandleDelegate_LaunchFilterDialog);
    
                  this.JSGridControl.SetDelegate(SP.JsGrid.DelegateType.GetAutoFilterEntries, HandleDelegate_GetAutoFilterEntries);
    
                  this.JSGridControl.SetDelegate(SP.JsGrid.DelegateType.AutoFilter, HandleDelegate_AutoFilter);
    
           }
    
     
    
    …
    
     
    
           function HandleDelegate_LaunchFilterDialog(columnKey) {
    
     
    
                  alert("HandleDelegate_LaunchFilterDialog called");
    
     
    
           }
    
           function HandleDelegate_GetAutoFilterEntries(currentAutoFilterState, initiatingColumnKey, columnKeys, fnSuccess, fnFailure) {
    
                  fnSuccess(columnKeys);
    
           }
    
           function HandleDelegate_AutoFilter(newState) {
    
     
    
                  _filter = newState;
    
                  _jsGridControl.Disable();
    
                  var args = Sys.Serialization.JavaScriptSerializer.serialize({
    
                         Command: "Filter",
    
                         FilterField: _filter[0].columnName,
    
                         FilterValue: _filter[0],
    
                         FilterOp: "Eq"
    
                  });
    
     
    
                  // Ajax Call with ‘args’ as argument.
    
                  eval(callbacks.filterCallback);
    
     
    
           }
    
    …
    
    }

    Thanks a lot

    Tuesday, February 5, 2013 5:17 PM