This is a migrated thread and some comments may be shown as answers.

Filter window on document center

1 Answer 23 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Yohan
Top achievements
Rank 2
Yohan asked on 17 Feb 2014, 09:49 AM
Hello,

I've noticed that pivot grid filter window displays relative to the pivot grid. I want to set the filter window on the center of the browser window. I've tried set_left,set_top client side functions with filter window OnClientShow event but it didn't work. Provide me with a code sample to achieve this. 

Thanks and Regards,
Yohan

1 Answer, 1 is accepted

Sort by
0
Venelin
Telerik team
answered on 20 Feb 2014, 09:00 AM
Hello Yohan,

Here I created an example implementation of the desired functionality.

1. Subscribe to the OnPivotGridCreated client-side event:

<ClientEvents OnPivotGridCreated="onPivotCreated"/>

2. Define the event handler as follows:

function onPivotCreated(sender, args) {
                 
    setTimeout(function () {
        var pivotFilterWindow = $telerik.getElementByClassName(window, 'PivotGridWindow');
        if (pivotFilterWindow) {
            pivotFilterWindow.style.left = 50 + '%';
            pivotFilterWindow.style.marginLeft = -1 * pivotFilterWindow.offsetWidth/2 + 'px';
        }
    });
                 
    if (sender.get_filterWindow()) {
        sender.get_filterWindow().add_dragStart(function () {
            $telerik.getElementByClassName(window, 'PivotGridWindow').style.marginLeft = 0;
        });
    }
}

The handler consists two parts, in the first, in the timeOut we retrieve the DOM element of the widow and set its left and margin-left properties accordingly. The second where I attach a dragStart handler to the RadWindow control removes the negative margin on drag start in order to prevent the control from "jumping" while dragging.

That's it, I also attach a test project, that you can review for further reference.

Regards,
Venelin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
PivotGrid
Asked by
Yohan
Top achievements
Rank 2
Answers by
Venelin
Telerik team
Share this question
or