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

Postback on mouse drag selection

2 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Cowan
Top achievements
Rank 1
David Cowan asked on 27 Feb 2012, 10:57 PM
I need to perform a postback on drag selection.  I currently use

OnMouseUp="GridMouseUp(this, event)" on the RadGrid element to call

function GridMouseUp(sender, e) {
    setTimeout(function () {
        var grid = $find(window.gridId);
        if (grid != null && grid.get_masterTableView().get_selectedItems().length > 0) {
            __doPostBack(window.gridUniqueId);
        }
    }, 0);
}

This works for the drag select case but also does postbacks when clicking on the filter textboxes which I do not want.  Is there any way in client code to detect OnMouseUp of a Drag select action?

2 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 01 Mar 2012, 03:17 PM
Hi,

 You can check the target element of the DOM event and if it is a table row (or cell) then the mouse up has happened on a grid item and should cause a postback. Here is a sample code

var e = e ? e : window.event;
var target = e.srcElement ? e.srcElement : e.target;
if (target.tagName.toLowerCase()=="td" && target.parentElement.id)
{
        //mouseup on a grid item - do postback
}

All the best,
Marin
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David Cowan
Top achievements
Rank 1
answered on 01 Mar 2012, 09:43 PM
This worked great
Tags
Grid
Asked by
David Cowan
Top achievements
Rank 1
Answers by
Marin
Telerik team
David Cowan
Top achievements
Rank 1
Share this question
or