Speed-up data entry

ASP.NET, PHP, Tutorials

Note: this code was updated and is compatible with version 10.x of PHPRunner, ASPRunner.NET and ASPRunnerPro.

We continue series of posts that show how to make you PHPRunner/ASPRunnerPro/ASPRunner.NET apps behave in Excel-like way. In this article we’ll show how you can speed-up data entry in inline mode eliminating the need to click ‘Inline Add’ and ‘Save’ buttons multiple times.



Here is the code that needs to be added to List page: Javascript OnLoad event. Now you can click ‘Inline Add’ once and just type in your data pressing tab to move from field to field. This script does the rest of the job.

    pageObj.addNewRecordsToBottom = false;      
      
    if($("[data-itemtype=pagination]").length==0)  
        $("").insertAfter($("body").find("div").last());  
         
    th_id1 = "";      
    th_id2 = "";      
    th_key = 0;    
      
    $("body").keydown(function(e) {    
        if(e.keyCode == 9){  
            if(e.target.id.substring(0,6) != "radio_"){  
                pos = e.target.id.lastIndexOf("_");      
                if(pos>0)      
                    th_key = e.target.id.substring(pos+1);      
            }  
            else{  
                pos = e.target.id.lastIndexOf("_");      
                elem = e.target.id.substring(0,pos);      
                pos = elem.lastIndexOf("_");      
                if(pos>0)      
                    th_key = elem.substring(pos+1);      
            }  
        }      
    });      
         
    $("body").keyup(function(e) {      
        if(e.keyCode == 9) {      
             spanID = $(e.target).parent()[0].id.substring(0,4);  
	     var multiselect = false;
	     if(e.target.id=="" && $(e.target).closest("div").siblings("select").attr("multiple")=="multiple")
		var multiselect = true;
             if( spanID != "edit" && e.target.id.substring(0,6) != "radio_" && e.target.id.substring(0,6)!="addnew"  && !multiselect){      
                $("#saveLink"+th_key).click();      
                $("#inlineAdd"+pageid).click();      
            }      
        }      
    });     

5 thoughts on “Speed-up data entry

  1. An article like this should have at least a little explanation of code. Looks like “if the keycode is something then the target is something.” The writer knows exactly what this does and should explain it.

  2. Terrific, only one aditional help, when y have two aditional tables using link properties (a master and two or more details) i am in the second table and add inline record, when press tab the site add a record to the first table. There are some aditional data to ensure this code works on the specific table.

    best regards
    Carlos.

  3. This could be very helpful to my project which is to replace an excel time sheet entry form where you have 1st column is a list of projects and top row are weekdays (like a calendar) Just need to figure out how to make the layout!

  4. While , this is a great feature, Does not work if you are in master with details. Also when in regular table the details link does not fill in. You have to do a reload for the links to show.

Leave a Reply

Your email address will not be published. Required fields are marked *