Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20697
| From | "Mel Smith" <med_cutout_syntel@aol.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | My (so-called) solution |
| Date | 2013-07-18 09:50 -0600 |
| Message-ID | <b4qh5oFboplU1@mid.individual.net> (permalink) |
| References | <b4lmlbFakaoU1@mid.individual.net> <ujk9s07ccty2.18d53e04mzn7z.dlg@40tude.net> <b4m79bFe157U1@mid.individual.net> <1rqamz10aphh7$.yzerntlnqpx2.dlg@40tude.net> |
JJ said:
> Are you trying to create an Excel-like table?
Hi JJ:
I 'may' be treating this like excel -- but I've never used Excel, except
to dump stuff into a database, but YES, I wish to create an easily navigable
and editable table.
To review:
- I have a 13-column table with the six columns on the far right
easily traversible and 'editable'.
- The number of rows is variable and unpredictable and modifiable by
the user.
- Currently, there are approx 19000+ pages that are available for
editing.
- Column 1 on the far left of the data rows is a button that says:
'Delete this Row'.
- Column 1 in the header row has a button that says 'Add a New Row'.
- Columns 2 thru 7 are readonly and mirror the editable columns 8
thru 13.
- All editable cells have a tabIndex with the root index at 201 and
extending
left to right and then down thru the rows.
- Every time a row is inserted or deleted, I rebuild the tabIndexes
for all editable cells.
- I also build /rebuild two arrays (1)- Holds editable objects, and
(2) Holds the associated tabIndex for the Object
- I access the index array (2) looking for the next tabIndex, then
pick out the associated object to focus on next.
I want to have my editable cells easily navigable thru using the
following keys: <tab><shift-tab>,<enter>,
<home>, <end>, <PgUp>,<PgDn>, <Up-Arrow>,<Down-Arrow>.
On each keydown, I 'listen' for these movement keys above, then I access
the two functions shown below:
Finally, this is working fine right now, and I don't need IDs to
navigate
My next step is to validate the input values in each of the 6 editable
columns. I'll do this *whenever* the user leaves an editable cell
Thanks for your guidance !
-Mel Smith
******************************************
function getnextobj(elindex,elname,nextdir,currobj) {
var nextindex,nextobj,nval,latleftcol,latrightcol ;
nextobj = currobj ; // default object
nextindex = elindex ;
// un-declared vrbls below are defined at the global level for
// other functins to access
// now search thru the aobjs and aindexes for the *next* index
switch (nextdir) {
case "goup" :
nextindex = elindex - numcols ;
break ;
case "godown" :
nextindex = elindex + numcols ;
break ;
case "gofwd" :
nextindex = elindex + 1 ;
break ;
case "gobak" :
nextindex = elindex - 1 ;
break ;
case "gohome" :
while (nextindex > mintab) { // move left to first column
nval = nextindex - (mintab-1) // e.g., 210 - (201-1) is 10
latleftcol = ((nval % numcols) === 1 ) ? true : false ;
if (latleftcol) break ;
nextindex-- ;
}
break ;
case "goend" :
while (nextindex < maxtab) { // move right to last column
nval = nextindex - (mintab-1) // e.g., 210 - (201-1) is 10
latrightcol = ((nval % numcols) === 0 ) ? true : false ;
if (latrightcol) break ;
nextindex++ ;
}
break ;
case "gopgup" :
while (nextindex >= (mintab+numcols) ) {
nextindex -= numcols ;
}
break ;
case "gopgdn" :
while (nextindex <= (maxtab-numcols) ) {
nextindex += numcols ;
}
break ;
}
if (nextindex < mintab || nextindex > maxtab) return nextobj ;
nextobj = srchobjs(nextindex,nextobj) ; // using default nextobj
return nextobj ;
}
function srchobjs(nindex,oldobj) {
var i,nextobj ;
var nlen = aobjs.length ;
for (i=0;i < nlen;i++) { // loop for next index to focus on
if (aindexes[i] === nindex) {
nextobj = aobjs[i] ; // get the object with the correwct index
return nextobj ; // this is the next object to focus on
}
}
return oldobj ;
}
****************************************
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
tabIndex to Input Object ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-07-16 13:53 -0600
Re: tabIndex to Input Object ?? JJ <duh@nah.meh> - 2013-07-17 05:06 +0700
Re: tabIndex to Input Object ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-07-16 18:36 -0600
Re: tabIndex to Input Object ?? JJ <duh@nah.meh> - 2013-07-17 10:44 +0700
My (so-called) solution "Mel Smith" <med_cutout_syntel@aol.com> - 2013-07-18 09:50 -0600
csiph-web