Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to focus second Cell when add a new row in dojo.gridX

I am using dojo.gridx to display my values. Sometimes user can create a new row. So that I have added a new button when click newRow button, will call onclick method.

In that method has create new row codes. My codes are below.

addRow:

function() {
    var that = this;
    var gridIdLocal = dijit.byId('GridId');

    that.lastIndex+=1;  ( last index count I get externally)    
    var newRow = {
        Id : '',
        ClassDES:'',
        createdDate: that.getTodayDate(),
        activatedDate:that.getTodayDate(),
        deactivedDate:'',
        activeStatus:'Y',
        id : lastIndex
    };
    gridIdLocal.store.newItem(newRow);
    gridIdLocal.store.save();            
}, 

By this code I am able to create a new row but I want to focus my mouse cursor point to newly added row's second column(ClassDES).
How can I achieve this functionality in dojo.gridx?

like image 814
KSK Avatar asked Jul 22 '15 07:07

KSK


People also ask

What is Dojo grid?

Basically a grid is a kind of mini spreadsheet, commonly used to display details on master-detail forms. From HTML terms, a grid is a “super-table” with its own scrollable viewport. Dojo Toolkit offers three different Grid widgets: dojox.grid.DataGrid. A visual grid/table much like a spreadsheet.


1 Answers

I havent used Dojo gridx, but looking at one of its basic demos, it is rendering a <table> within <div> for each row. Using newRow object from your example above, you could do something like following with jquery

function() {
    var that = this;
    var gridIdLocal = dijit.byId('GridId');

    that.lastIndex+=1;  ( last index count I get externally)    
    var newRow = {
        Id : '',
        ClassDES:'',
        createdDate: that.getTodayDate(),
        activatedDate:that.getTodayDate(),
        deactivedDate:'',
        activeStatus:'Y',
        id : lastIndex
    };
    gridIdLocal.store.newItem(newRow);
    gridIdLocal.store.save();  

    $(newRow).find("td")[1].children("input").focus();
}, 

If you could post a working jsfiddle, it would be easier to solve.

like image 87
Saharsh Avatar answered Sep 22 '22 04:09

Saharsh