Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Streamline JavaScript in RadGrid

I have a Telerik RadGrid nand in the Client Settings I have a row doublke click event that launches to JavaScript below.

I've used this script for years...
Just wondering, could this be streamlined a bit?

function OnRowDblClick(sender, eventArgs) {
    var grid = sender;
    var MasterTable = grid.get_masterTableView();
    var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
    var cell = MasterTable.getCellByColumnUniqueName(row, "id");
    var value = cell.innerHTML
    window.location.href = 'usersEdit.aspx?e=1&id=' + value; // Redirect the page           
    return;
}

Open in new window

Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

which part of the code you wish to be "streamlined"?
the code is readable and straightforward, why would u want to change it?
Avatar of Larry Brister

ASKER

sedgewick,
  I'm not sure it does need to be streamlined...I'm not a JavaScript expert.

Hence...my question.
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
a good example of streamline is using switch instead of multiple if else.
or using $.each or $.grep instead of something like (for i=0;i<length;i++){}

its alot depends of the use case and the result you wish to produce from your code.
hope it was clear...
Thanks.  I appreciate your comments.

Like a lot of .Net developers, my true knowledge of JavaScript is not extensive.