Nevron Open Vision Documentation
Master - Details

About Master - Details

Master - Details is a feature of the Table Grid that allows you to display additional information (details) for each NRecordDataRow (i.e. for each record). The following image demonstrates a master - details table grid:

In the image above the details for each person show the orders that are associated with that person. The details are managed by the NMasterDetails element, that can be accessed by the MasterDetails property. The following code example achieves the master - details grid shown above:

Master - Details Example
Copy Code
// create a view and get its grid
NTableGridView view = new NTableGridView();
NTableGrid grid = view.Grid;
// bind the grid to personsDataSource
grid.DataSource = personsDataSource;
// get the grid master details
NMasterDetails masterDetails = grid.MasterDetails;
// creater the table grid detail. It shows information from the personOsOrdersDataSource 
NTableGridDetail detail = new NTableGridDetail();
detail.DataSource = personOsOrdersDataSource;
// the details are bound using field binding
NRelationMasterBinding masterBinding = new NRelationMasterBinding();
masterBinding.Relations.Add(new NRelation("Id", "PersonId"));
detail.MasterBinding = masterBinding;
// configure the details grid
detail.GridView.Grid.AllowEdit = false;

The Table Grid can display multiple details for each record data row. The details are contained inside the NDetailCollection, which is accessible from the Details property of the NMasterDetails element. The details are represented by objects that derive from the NDetails element. The following image shows the current details hierarchy:

Following are details for the classes in the hierarchy:

Details Presenter

The details presenter is represented by an object that is derived from NDetailsPresenter class and an instance of which is accessible from the DetailsPresenter property of the NMasterDetails class. The details presenter is responsible for two things:

  1. Given the count of the details in the details collection, determine the number of rows that are needed to show these details.
  2. Create the NDetailsCell instances for each details row. 

If a details presenter is not assigned to the NMasterDetails.DetailsPresenter property, by default the grid shows each detail in a single cell, positioned on a separate row.

The following image shows the current NDetailsPresenter class hierarchy:

As you can see currently there are two types of details presenters:

  1. NTabDetailsPresenter - this details presenter shows the details in a single NDetailsCell that contains a NTab widget. Each tab page represents a single detail widget. The tab pages titles are obtained from the Title property of each NDetail instance.
  2. NCustomDetailsPresenter - this details presenter gives the developer the ability to provide a custom details presentation, as shown in the following example:

    Custom Details Presenter
    Copy Code
    NCustomDetailsPresenter customDetailsPresenter = new NCustomDetailsPresenter();
    tableGrid.MasterDetails.DetailsPresenter = customDetailsPresenter;
    customDetailsPresenter.GetDetailsRowCountDelegate = delegate(NCustomDetailsPresenterGetDetailsRowCountArgs args) 
        // represent the details in a single row, unless there are no details
        return args.DetailCollection.Count == 0 ? 0 : 1;
    customDetailsPresenter.CreateDetailRowCellsDelegate = delegate(NCustomDetailsPresenterCreateDetailRowCellsArgs args) 
        // create a list of [detail:widget] for all details that can create widgets
        NList<NKeyValuePair<NDetail, NWidget>> detailsWidgets = new NList<NKeyValuePair<NDetail, NWidget>>();
        int count = args.DetailCollection.GetChildrenCount();
        for (int i = 0; i < count; i++)
            NDetail detail = args.DetailCollection[i];
            NWidget widget = detail.CreateWidget(args.MasterDataSource, args.MasterRowIndex);
            if (widget != null)
                detailsWidgets.Add(new NKeyValuePair<NDetail, NWidget>(detail, widget));
        // no detail widgets -> embed nothing in the details row
        if (detailsWidgets.Count == 0)
            return null;
        // single details -> embed it in the details row
        if (detailsWidgets.Count == 1)
            return new NDetailsCell[] { new NDetailsCell(detailsWidgets[0].Value) };
        // create a stack of group boxes
        NStackPanel stack = new NStackPanel();
        for (int i = 0; i < detailsWidgets.Count; i++)
            NKeyValuePair<NDetail, NWidget> detailsWidget = detailsWidgets[i];
            NGroupBox groupBox = new NGroupBox(detailsWidget.Key.Title);
            groupBox.Content = detailsWidget.Value;
        return new NDetailsCell[] { new NDetailsCell(stack) };


Send Feedback