Loading ...
Sorry, an error occurred while loading the content.

23414Re: [ydn-javascript] Re: get cell value of selected row in datatable. Help plzzzzzzzzzzzzzz!!!

Expand Messages
  • Satyam
    Jan 4, 2008
    • 0 Attachment
      You can listen to rowSelectEvent:

      http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#rowSelectEvent

      To read the value of any field within the row you just need to do something
      like this:

      myDataTable.subscribe('rowSelectEvent',function (oArgs) {
      alert(oArgs.record.getData('fieldName'));
      });

      Satyam

      ----- Original Message -----
      From: "balaragunath" <balaragunath@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Friday, January 04, 2008 5:54 AM
      Subject: [ydn-javascript] Re: get cell value of selected row in datatable.
      Help plzzzzzzzzzzzzzz!!!


      > Hi,
      >
      > How can i trigger the same function 'getValueCellOfSelectedRow' on the
      > select of the row in datatable??
      >
      > --- In ydn-javascript@yahoogroups.com, "manhtuanquan78"
      > <manhtuanquan78@...> wrote:
      >>
      >> //and code:
      >> function getValueCellOfSelectedRow(colName){
      >> var i, j, k, l, aRecords;
      >> var oPaginator = this.myDataTable.updatePaginator();
      >>
      >> // Paginator is enabled, show a subset of Records and update
      >> Paginator UI
      >> if(this.myDataTable.get("paginated")) {
      >> var rowsPerPage = oPaginator.rowsPerPage;
      >> var startRecordIndex = (oPaginator.currentPage - 1) *
      >> rowsPerPage;
      >> aRecords = this._oRecordSet.getRecords(startRecordIndex,
      >> rowsPerPage);
      >> this.formatPaginators();
      >> }
      >> // Show all records
      >> else {
      >> aRecords = this.myDataTable._oRecordSet.getRecords();
      >> }
      >>
      >> var elTbody = this.myDataTable._elTbody;
      >> var elRows = elTbody.rows;
      >>
      >> if(YAHOO.lang.isArray(aRecords) && (aRecords.length > 0)) {
      >> ///this.myDataTable.hideTableMessage();
      >>
      >> // Keep track of selected rows
      >> var indexRow = this.myDataTable.getSelectedRows();
      >>
      >> if(indexRow != null && indexRow != ""){
      >> elRow = this.myDataTable.getTrEl(parseInt(indexRow));
      >>
      >> //Kiem tra tat ca cac cot neu trung ten voi colName thi
      >> lay gia tri
      >> var keyIndex = 0;
      >> for(i=0; i<this.myDataTable._oColumnSet.keys.length; i++) {
      >> oColumn = this.myDataTable._oColumnSet.keys[i];
      >> var colKey = oColumn.getKey();
      >>
      >> if(colKey == colName){
      >> keyIndex = i;
      >> }//end if(colKey == colName)
      >> }//end for(i=0...
      >>
      >> var valCell = elRow.cells[keyIndex].innerHTML;
      >> alert(valCell);
      >> }//end if(indexRow != null)
      >> else{
      >> alert("No row is selected");
      >> }
      >> }//end if(YAHOO.lang.isArray(aRecords
      >>
      >> }
      >>
      >> --- In ydn-javascript@yahoogroups.com, "manhtuanquan78"
      >> <manhtuanquan78@> wrote:
      >> >
      >> > Hi All.
      >> > I want to setup a method:
      >> > function getCellValueOfSelectedRow(colName){
      >> > //TODO : how to do it???
      >> >
      >> > return cellValue
      >> > }
      >> >
      >> > In that:
      >> > -@parameter is: - colName: column Name
      >> > - purpose of method: get value of cell in seleted row with
      > column name
      >> > For example: I have a datatable:
      >> > COL1 | COL2 | COL3
      >> > ---------------------
      >> > aaa | bbb | ccc
      >> > ddd | eee | fff
      >> > ggg | hhh | kkk
      >> >
      >> > ( only second row is selected)
      >> > If i call method: getCellValueOfSelectedRow("COL3") -> It will return
      >> > "fff"
      >> >
      >> > How to setup this method??? Please help me. THank you!
      >> >
      >>
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.516 / Virus Database: 269.17.13/1207 - Release Date:
      > 02/01/2008 11:29
      >
      >
    • Show all 6 messages in this topic