YUI datatable - query XML for specific data

zeu5

New Member
hoping someone can help, I've spent hours searching the internet for an answer but have found nothing (that I understand).I have this datatable code that works fine -\[code\]YUI().use("datasource-io", "datatable-base", "datasource-xmlschema", "datatabledatasource", "io", "datasource-textschema", "datasource-get", function(Y) {YAHOO.util.Event.addListener(window, "load", function() {YAHOO.example.EnhanceFromMarkup = function() { var myColumnDefs = [ {key:"userid", sortable:true, resizeable:true}, {key:"firstname", sortable:true, resizeable:true}, {key:"surname", sortable:true, resizeable:true}, ]; var myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("users_table")); myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; myDataSource.responseSchema = { fields: [{key:"userid"}, {key:"firstname"}, {key:"surname"}, ] }; var myDataTable = new YAHOO.widget.DataTable("markup", myColumnDefs, myDataSource, {sortedBy:{key:"userid",dir:"asc"}} ); return { oDS: myDataSource, oDT: myDataTable };}();});\[/code\]and it creates a datatable from this (test) XML -\[code\]<users type="array"><user><created-at type="datetime">2011-08-31T21:56:29Z</created-at><firstname>Amy</firstname><id type="integer">1</id><surname>Hebron</surname><updated-at type="datetime">2011-08-31T22:28:27Z</updated-at><userid type="integer">1</userid></user><user><created-at type="datetime">2011-08-31T21:56:41Z</created-at><firstname>Joe</firstname><id type="integer">2</id><surname>Asher</surname><updated-at type="datetime">2011-08-31T22:28:34Z</updated-at><userid type="integer">2</userid></user> </users>\[/code\]What I really need to do now is find a way to bring back only certain data, for example, only records with an id of 2.I did find some examples that used a query string in the 'initialResponse' part...but I can't find anything that demonstrates what I need, which would be something like - "return all records with an id of 2".Or is there a better way of doing it?(in case it's important, by XML data is being provided by a rails table.)Edit - By the way I'm fairly new to all this, so would need a non-cryptic answer :)Generic rails controller code to generate XML (cant get this to display as code) -\[code\]def index\[/code\]@ items = Item.allrespond_to do |format|format.htmlformat.xml {render :xml => @ items }end end
 
Top