Solved

Streamline JavaScript in RadGrid

Posted on 2013-01-02
5
375 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
ID: 38739724
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
ID: 38739868
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
ID: 38740154
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
ID: 38740163
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
ID: 38740171
Thanks.  I appreciate your comments.

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

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…

840 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