Datagrid paging

How can I implement data grid paging? So the viewer sees the first 5 rows for example, then click forward or back to see the next 5 etc.

Hi David,

You can implement data grid paging in the following manner:

1) create a data cube with your data source

2) Add a calculated element transform that assigns a page number to each row. The expression below will return 10 rows at a time.

<!--[if !vml]-->

Image title

<!--[if !vml]--><!--[endif]-->

3) Switch this measure ‘Page’ to a hierarchy.

4) Now, go to the dashboard and add the data grid

5) Add the Page hierarchy to the Slicers in the Data Analysis Panel

6) You can add buttons and labels as follows:

<!--[if !vml]-->

Image title


7) Create a view Parameter and bind it to the Page hierarchy

8) Add the following script in the click event of the Previous button:

var page = parseInt(window.dundas.context.baseViewService.currentView.control.viewParameters[1].parameterValue.values[0].uniqueName.split("."))-1;

if (page == -1)

{

page = 0;

}

// Set parameter value

var newValue = page;

var newUniqueName = newValue + '.Page';

var parameters = window.dundas.context.baseViewService.currentView.control.viewParameters;

// get first view parameter

var param = parameters[1];

param.parameterValue.token = null;

param.parameterValue.values = [];

param.parameterValue.values.push(new dundas.data.MemberValue({hierarchyUniqueName: 'Page', levelUniqueName: 'Page', uniqueName : newUniqueName}));

param.loadAffectedAdaptersData();

//update label

pageLabel.labelText = page.toString();


9) Add the following script to the click event of the Next button:

var page = parseInt(window.dundas.context.baseViewService.currentView.control.viewParameters[1].parameterValue.values[0].uniqueName.split("."))+1;

if (page >= parseInt(pageMax.control._processedText))

{

page = parseInt(pageMax.control._processedText);

}

// Set parameter value

var newValue = page;

var newUniqueName = newValue + '.Page';

var parameters = window.dundas.context.baseViewService.currentView.control.viewParameters;

// get first view parameter

var param = parameters[1];

param.parameterValue.token = null;

param.parameterValue.values = [];

param.parameterValue.values.push(new dundas.data.MemberValue({hierarchyUniqueName: 'Page', levelUniqueName: 'Page', uniqueName : newUniqueName}));

param.loadAffectedAdaptersData();

//update label

pageLabel.labelText = page.toString();



The scripts above will also update the labels with the correct page number.