[ 4 posts ]

Vovan

  • Username: Vovan222
  • Joined: Sun Jan 09, 2011 4:51 am
  • Posts: 40
  • Offline
  • Profile

Getting of selected records

Post Posted: Sat Aug 18, 2012 11:14 am
+0-
I need to get an all selected records of my DataTable. I know that oDataTable's getSelectedRows method returns selected rows as an array of Record IDs. But I need to get an instance Records instead. Which is method should I use for my purposes?

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: Getting of selected records

Post Posted: Sat Aug 18, 2012 11:30 am
+0-
Have you read DataTable API getRecord ?

Why can't you just loop over the .getSelectedRows array and use .getRecord to return a record and do what you want with it?

Vovan

  • Username: Vovan222
  • Joined: Sun Jan 09, 2011 4:51 am
  • Posts: 40
  • Offline
  • Profile

Re: Getting of selected records

Post Posted: Sat Aug 18, 2012 10:48 pm
+0-
I don't want to use a loop I'm looking for an corresponding method.

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: Getting of selected records

Post Posted: Sun Aug 19, 2012 9:33 am
+0-
There is no such method, and 2.9 is no longer supported .... so,

Code:
var recIndices = myDT.getSelectedRows();
var recs = [];
for(var i=0; i<recIndices.length; i++)
  recs.push( myDT.getRecord(recIndices[i]) );

// leaves you with recs an Array of Records ....

// if you want a recordset of only the selected ones ... follow up with,

var newRS = new YAHOO.widget.RecordSet();
newRS.addRecords(recs);
  [ 4 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum