|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Datatable - select first record when data has been (re)fetched and tbl. is drawnHi, I am trying to select the first record of a datatable as soon as the data has arrived. Data is coming in via async-request and the table can be reused for several requests. I searched half the day, but I could not find a suitable event to subscribe to. I found "dataReturnEvent" and "renderEvent". However dataReturnEvent fires before the table is repopulated and so YAHOO.ddTech.AppointTable.oDataTable.subscribe( "dataReturnEvent", function(oArgs, oEl) { var nRecords = oArgs.response.results.length; if (nRecords > 0) { // Programmatically select 1st row and // set focus to the dataTable oEl.selectRow(oEl.getTrEl[0]); oEl.focus(); } else { // No records returned, so focus on the // first control for adding new data... anotherObject.focus() } }, YAHOO.ddTech.AppointTable.oDataTable, true ); does not have the disired effect, as at that time there simply are no TR's to select. "renderEvent" on the other hand for some reason has not been very impressed of my subscribing to it. It never seems to fire for me. Also, I have been desperately searching for a rowCount property but the best I could find was to do something like var nRecords = this.getRecordSet().getLength(); Thanks in advance for any help Kind regards from Berlin Frank, |
|
|
Re: Datatable - select first record when data has been (re)fetched and tbl. is drawndataReturnEvent fires when data has arrived, before it was processed. renderEvent upon re-rendering the table except for the first time around. The first time initEvent gets fired, that's the one you are looking for.
Satyam dietrich.frank wrote: > Hi, > > I am trying to select the first record of a datatable > as soon as the data has arrived. Data is coming in via > async-request and the table can be reused for several requests. > > > > > > I searched half the day, but I could not find a suitable event to > subscribe to. > > I found "dataReturnEvent" and "renderEvent". However > dataReturnEvent fires before the table is repopulated and so > > YAHOO.ddTech.AppointTable.oDataTable.subscribe( > "dataReturnEvent", > function(oArgs, oEl) { > var nRecords = oArgs.response.results.length; > > if (nRecords > 0) { > // Programmatically select 1st row and > // set focus to the dataTable > > oEl.selectRow(oEl.getTrEl[0]); > oEl.focus(); > > } > else { > // No records returned, so focus on the > // first control for adding new data... > > anotherObject.focus() > > } > }, > YAHOO.ddTech.AppointTable.oDataTable, > true > ); > > > does not have the disired effect, as at that time there simply are no > TR's to select. > > "renderEvent" on the other hand for some reason has not been very > impressed of my subscribing to it. It never seems to fire for me. > > Also, I have been desperately searching for a rowCount property but > the best I could find was to do something like > > var nRecords = this.getRecordSet().getLength(); > > > Thanks in advance for any help > > Kind regards from Berlin > > Frank, > > > > > > > > > ------------------------------------ > > Yahoo! Groups Links > > > > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.4.5/1537 - Release Date: 06/07/2008 5:26 > > > > |
|
|
Re: Datatable - select first record when data has been (re)fetched and tbl. is drawnsorry, small typo. > oEl.selectRow(oEl.getTrEl[0]); should be oEl.selectRow(oEl.getTrEl(0)); minor update: I am meanwhile doing it by employing window.setTimeout() from within the "dataReturnedEvent", witch I find lousy and dirty, but seems to work until I find a better solution: so it's oDataTable.subscribe( "dataReturnedEvent", function(oArgs) { if (oArgs.response.results.length > 0) { window.setTimeout( function() { var oTable = YAHOO.ddTech ... oDataTable; oTable.selectRow( oTable.getEl(0) ); oTable.focus(); }, 500 ); } else { selectAnotherControl.focus(); } } ); |
|
|
Re: Datatable - select first record when data has been (re)fetched and tbl. is drawnSatyam,
> dataReturnEvent fires when data has arrived, > before it was processed. Thanks, yes, that's why I can't properly use it. > renderEvent upon re-rendering the table except for the > first time around. YAHOO.ddTech.AppointTable.oDataTable.subscribe( "renderEvent", function() { alert("render event"); } ); never seems to fire. I have the dataTable in a dialog that I simply show and hide and so reuse the table more than once. On subsequent calls I do oTable.initializeTable(); oTable.render(); oTable.showTableMessage( DataTable.MSG_LOADING ); oDS.sendRequest( cPostData, oTable.onDataReturnInitializeTable, oTable); Hmmm... is it maybe due to the initializeTable ??? and then each time firing the initEvent??? thanks Satyam, I'll give it a shot and let You know. > The first time initEvent gets fired, > that's the one you are looking for. I'll see, if in my scenario each request is the "first request" :D Satyam, it's Sunday here - why the hell are You online anyway ? |
|
|
Re: Datatable - select first record when data has been (re)fetched and tbl. is drawnSatyam, > ...renderEvent upon re-rendering the table except > for the first time around. The first time initEvent > gets fired, that's the one you are looking for. Perfect! yes indeed initEvent is firing every time I populate or repopulate the dataTable. Honestly I would have never come to that idea, as I never destroy the datatable and was associating initEvent with the constructor and not assuming it would also fire after calling initializeTable() (whitch of course I also did not have in focus when searching for the "bug"). So in case anyone else needs it, this it what works even on subsequent repopulating the dataTable: YAHOO.ddTech....oDataTable.subscribe( "initEvent", function() { var oTable = YAHOO.ddTech...oDataTable; var nRecords = oTable.getRecordSet().getLength(); if (nRecords > 0){ // Programmatically select first row // and set focus to the table oTable.selectRow(oTable.getTrEl(0)); oTable.focus(); } else { theOtherControl.focus(); } } ); Thanks for pointing me in the right direction. Regards Frank |
| Free Forum Powered by Nabble | Forum Help |