A newer version of this page is available. Switch to the current version.

ProcessCustomBinding - Available Binding Delegates

  • 3 minutes to read

To delegate the implementation of a grid view model population to Model-layer functions, call the view model's VerticalGridModel.ProcessCustomBinding method in a Controller. This method has several overloads with different sets of parameters. The result of the method call is that the intrinsic VerticalGrid view model object (VerticalGridModel) will be populated with the requested data. The view model object can then be passed to the VerticalGrid's Partial View as a Model and bound to the VerticalGrid with the extension's VerticalGridExtension.BindToCustomData method.

Method Overloads

From the following list of available overloads, you can select a specific overload depending on specific data processing features (such as sorting, filtering, paging) used within the VerticalGrid.

Overload List - C#

public void ProcessCustomBinding( VerticalGridCustomBindingGetDataColumnCountHandler getDataColumnCountMethod,
VerticalGridCustomBindingGetDataHandler getDataMethod );

public void ProcessCustomBinding( VerticalGridCustomBindingGetDataColumnCountHandler getDataColumnCountMethod,
VerticalGridCustomBindingGetDataHandler getDataMethod,
VerticalGridCustomBindingGetUniqueHeaderFilterValuesHandler getUniqueHeaderFilterValuesMethod );

public void ProcessCustomBinding( VerticalGridCustomBindingGetDataColumnCountHandler getDataColumnCountMethod,
VerticalGridCustomBindingGetDataHandler getDataMethod,
VerticalGridCustomBindingGetSummaryValuesHandler getSummaryValuesMethod );

public void ProcessCustomBinding( VerticalGridCustomBindingGetDataColumnCountHandler getDataColumnCountMethod,
VerticalGridCustomBindingGetDataHandler getDataMethod,
VerticalGridCustomBindingGetSummaryValuesHandler getSummaryValuesMethod,
VerticalGridCustomBindingGetUniqueHeaderFilterValuesHandler getUniqueHeaderFilterValuesMethod );

Method Parameters

The following list describes all available method parameters. Each parameter points to a typed method delegate.

Parameter Name Is Required? Delegated Method Type Description
getDataColumnCountMethod Required VerticalGridCustomBindingGetDataColumnCountHandler Always provide an implementation for the delegated method to return the total number of data columns.
getDataMethod Required VerticalGridCustomBindingGetDataHandler Always provide an implementation for the delegated method to return the data requested by the VerticalGrid.
getSummaryValuesMethod Optional VerticalGridCustomBindingGetSummaryValuesHandler If you use summaries within the VerticalGrid, provide an implementation for the delegated method to calculate and return values of the required summaries.
getUniqueHeaderFilterValuesMethod Optional VerticalGridCustomBindingGetUniqueHeaderFilterValuesHandler If you use filtering and display header filter buttons within the VerticalGrid, provide an implementation for the delegated method to return unique values to be displayed in the header filter popup list invoked for a VerticalGrid row.

Method Usage

The VerticalGridModel.ProcessCustomBinding method's simple usage scenario is given below - only required method delegates are specified.

Controller Code:


public partial class MyController: Controller {
        public ActionResult MyVerticalGrid() {
            return View("MyVerticalGrid");
        }
        //Standard VerticalGrid callback requests
        public ActionResult MyVerticalGridPartial() {
            var viewModel = VerticalGridExtension.GetViewModel("verticalGrid"); //Obtain the VerticalGrid's state - the VerticalGridModel object
            ...
            viewModel.ProcessCustomBinding( //Call method with two required parameters
                MyBindingHandlers.MyGetDataColumnCount, //Function to return the total number of data columns in a model
                MyBindingHandlers.MyGetData //Function to return data columns requested by the VerticalGrid
            );
            return PartialView("MyVerticalGridPartial", viewModel);
        }
        ...
    }

The following code sample shows a more versatile way to use the VerticalGridModel.ProcessCustomBinding method.

Controller Code:


public partial class MyController: Controller {
        public ActionResult MyVerticalGrid() {
            return View("MyVerticalGrid");
        }
        //Standard VerticalGrid callback requests
        public ActionResult MyVerticalGridPartial() {
            var viewModel = VerticalGridExtension.GetViewModel("verticalGrid");
            if(viewModel == null)
                //Initialize the VerticalGrid state on the first load
                viewModel = CreateVerticalGridModel();
            return MyCustomBindingCore(viewModel);
        }
        //Paging operation requests
        public ActionResult MyPagingAction(VerticalGridPagerState pager) {
            var viewModel = VerticalGridExtension.GetViewModel("verticalGrid");
            viewModel.ApplyPagingState(pager); //Update the VerticalGrid state with the processed paging state
            return MyCustomBindingCore(viewModel);
        }
        //Sorting operation requests
        public ActionResult MySortingAction(VerticalGridRowState row, bool reset) {
            var viewModel = VerticalGridExtension.GetViewModel("verticalGrid");
            viewModel.ApplySortingState(row, reset); //Update the VerticalGrid state with the processed sorting state
            return MyCustomBindingCore(viewModel);
        }

        PartialViewResult MyCustomBindingCore(VerticalGridModel viewModel) {
            ... //Some code to delegate model population to Model-layer functions
            return PartialView("MyVerticalGridPartial", viewModel);
        }

        static VerticalGridModel CreateVerticalGridModel() {
            var viewModel = new VerticalGridModel();
            viewModel.KeyFieldName = "ID";
            viewModel.Rows.Add("From");
            viewModel.Rows.Add("Subject");
            viewModel.Rows.Add("Sent");
            viewModel.Rows.Add("Size");
            viewModel.Rows.Add("HasAttachment");
            return viewModel;
        }
    }
See Also