Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Streamline JavaScript in RadGrid

Posted on 2013-01-02
5
Medium Priority
?
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
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:
Meir Rivkin earned 2000 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:Meir Rivkin
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Suggested Courses

604 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