Expand TOLAPGrid Items on call back (Radar-soft MSAS Cube)

URL: http://radar-soft.com/products/radaraspnet_MSAS.aspx

Today I found some interesting event for TOLAP Grid. I had requirement like When user clicks on Parent item, I need to expand all available child items for that parent item.



In above TOLAPGrid I have Three Rows, BusinessType Description, Region Name, NDC Number. When Page is loading I need to show all available Business Types and associated Regions & NDC Numbers with collapsed mode.

By Deafault TOLAPGrid is providing a functionality as when you click on Parent, its showing immediate child item. But some times the requirement would be when you click on parent Item we need to show all available childs for that selected parent.




Practically it seems I need to do write some logic on onCallback event. Because when you click on Parent's item Page is not postbacking, its just callback is happening. But unfortunately I am not able to find any event data in this call. But we have another event as OnGridEvent. Here you can see all Grid operations, which are happening for each grid's operation on Grid's callback.

The following code expands parent items children on grid's callback.

//Expand Child Nodes When click on Parent Node.

protected void TOLAPGridSales_OnGridEvent(object Sender, TGridEventArgs EventArgs)

{

if (EventArgs.EventType == TGridEventType.geDrillAction)

{

THierarchy _hierarchy = TOLAPGridSales.AxesLayout.RowAxis(0);

TMember _member = _hierarchy.FindMemberByName(((TMember)EventArgs.Data[0]).DisplayName);

if (_member == null) return;

IMemberCell _membercell = TOLAPGridSales.CellSet.FindMember(_member);

for (int child = 0; child <>

_membercell.Children(child).DrillAction(TPossibleDrillActions.esNextHierarchy);

}

}


When you click on parent item, "geDrillAction" event will raise for each parent expand operation.

if (EventArgs.EventType == TGridEventType.geDrillAction)

1) Check
EventArgs.EventType is equals to Event Type geDrillAction.

2) Get Parent Hierarchy Row

THierarchy _hierarchy = TOLAPGridSales.AxesLayout.RowAxis(0);

3) Find Member by using Event's Data from collection of Parents(Here I am finding "Hospital Pharmacy" Item)

TMember _member = _hierarchy.FindMemberByName (((TMember)EventArgs.Data[0]).DisplayName);


4) Find Member Cell By using Member. (We cannot get child count by using Member, we can get child count by using member Cell.

IMemberCell _membercell = TOLAPGridSales.CellSet.FindMember(_member);

5) Try to get the child count of member cell and loop through the available childs to drillthrough the items.

for (int child = 0; child <>
_membercell.Children(child).DrillAction(TPossibleDrillActions.esNextHierarchy);

Thats it ... !!

Comments

Popular posts from this blog

Windows Azure Package Build Error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Resource ID : 1. The request limit for the database is 180 and has been reached.

How to get Client's Location using IPAddress