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

Re: how to filter JSARRAY datasource using sendRequest???

Expand Messages
  • y_lsmith
    ... Have a look at this page for inspiration: http://yuiblog.com/sandbox/yui/v251/examples/datatable/filtered_dt.html Hope this helps, Luke
    Message 1 of 2 , Jul 31, 2008
    • 0 Attachment
      --- In ydn-javascript@yahoogroups.com, "haazhelthorn"
      <haazhelthorn@...> wrote:
      >
      > Hi all,
      >
      > I'm noob about yui and I'm facing a problem on JSARRAY datasources
      > turning me crazy.
      > I'm trying to run a simple example using sendRequest in order to
      > filter data displayed in a datatable.
      > My problem is that my datasource is not filtered and sendRequest
      > always returns full array.
      > Can anyone help me to understand where I'm wrong???
      > Thx
      >
      > Here is piece of code :
      >
      > var array =[
      > {name:"Ashley",breed:"German Shepherd"},
      > {name:"Dirty Harry",breed:"Norwich Terrier"},
      > {name:"Abby",breed:"Labrador Retriever"},
      > {name:"Oscar",breed:"Yorkshire Terrier"},
      > {name:"Riley",breed:"Golden Retriever"},
      > {name:"Bob",breed:"Miniature Schnauzer"},
      > {name:"Shannon",breed:"Greyhound"},
      > {name:"Brandy",breed:"Boxer"},
      > {name:"Zoe",breed:"Labrador Retriever"}
      > ];
      > var myDataSource = new YAHOO.util.DataSource(array);
      > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
      > myDataSource.responseSchema = {
      > fields: ["name","breed" ]
      > };
      > myDataSource.flushCache();
      > var oCallback = {
      > success: function(oRequest,oResponse,oPayload) {
      > msg = "Hi ! There are " + oResponse.results.length + " answers for
      > "+oRequest+"\nError? "+oResponse.error;
      > for (i=0; i < oResponse.results.length; i++) {
      > dog = oResponse.results[i];
      > msg += "\n" + dog.name+" - "+dog.breed;
      > }
      > alert(msg);
      > },
      > failure: function(oRequest,oResponse,oPayload) {
      > alert("Hi " + oPayload + "! There were no Greyhounds found.");
      > },
      > scope: this,
      > argument: 'toto'
      > }
      > myDataSource.sendRequest("breed=Greyhound", oCallback);

      Have a look at this page for inspiration:
      http://yuiblog.com/sandbox/yui/v251/examples/datatable/filtered_dt.html

      Hope this helps,
      Luke
    Your message has been successfully submitted and would be delivered to recipients shortly.