Solved

Streamline JavaScript in RadGrid

Posted on 2013-01-02
5
369 Views
Last Modified: 2013-01-03
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

0
Comment
Question by:lrbrister
  • 3
  • 2
5 Comments
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
which part of the code you wish to be "streamlined"?
the code is readable and straightforward, why would u want to change it?
0
 

Author Comment

by:lrbrister
Comment Utility
sedgewick,
  I'm not sure it does need to be streamlined...I'm not a JavaScript expert.

Hence...my question.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
Comment Utility
in my opinion it doesn't.
usually you would like to streamline part of code if it's too long or not readable or something which can provide same result but the code looks cleaner.
for instance, alot of jquery api are "streamlined" of old-fashion code, like selectors and traversing.

bottom line no need to streamline, code is neat.

cheers
0
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
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...
0
 

Author Closing Comment

by:lrbrister
Comment Utility
Thanks.  I appreciate your comments.

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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now