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

Re: Help with results

Expand Messages
  • THECREW
    Jenny, I m still getting the same results. I replaced the following as you recommended. This is the code that I have to pull it out The oResultItem[0] works
    Message 1 of 7 , Jun 29, 2006
    • 0 Attachment
      Jenny,

      I'm still getting the same results. I replaced the following as you
      recommended. This is the code that I have to pull it out

      The oResultItem[0] works fine but when I try to grab a second result with
      oResultItem[1] the alert tells me that it is undefined. What am I going
      wrong? I have the return showing in an alert window and it is showing
      correct info. Please help.



      oACDS2 = new
      YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
      ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
      oACDS2.queryMatchContains = true;
      oACDS2.scriptQueryAppend = "output=json&returnto=AssignedTo"; //
      Needed for YWS

      // Instantiate auto complete
      oAutoComp2 = new
      YAHOO.widget.AutoComplete('AssignedTo','AssignedToReturn',
      oACDS2);

      oAutoComp2.formatResult = function(oResultItem, sQuery) {

      alert(oResultItem[0]);
      alert(oResultItem[1]);

      // This was defined by the schema array of the
      data source
      var sEmployeeID = oResultItem[0];
      //var sFirstName = oResultItem[1];
      //var sMarkup = sFirstName + sEmployeeId;
      var sMarkup = sEmployeeID;
      return (sMarkup);
      }

      --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@...> wrote:
      >
      > Hi Jim,
      >
      > This is a bug that has been fixed in the next release. Until then,
      > here's a code snippet that should give you a workaround. Replace the
      > JSON the switch block in the XHR DataSource's parseResponse() method
      > witht he following. Let me know how this works out for you -- I hope
      > it helps!
      >
      > Jenny
      >
      >
      > case this.TYPE_JSON:
      > var jsonList;
      > if(window.JSON) {
      > // Use the JSON utility if available
      > var jsonObjParsed = JSON.parse(oResponse);
      > if(!jsonObjParsed) {
      > bError = true;
      > break;
      > }
      > else {
      > // eval is necessary here since aSchema[0] is of
      > unknown depth
      > jsonList = eval("jsonObjParsed." + aSchema[0]);
      > }
      > }
      > else {
      > // Parse the JSON response as a string
      > try {
      > // Trim leading spaces
      > while (oResponse.substring(0,1) == " ") {
      > oResponse = oResponse.substring(1,
      > oResponse.length);
      > }
      >
      > // Invalid JSON response
      > if(oResponse.indexOf("{") < 0) {
      > bError = true;
      > break;
      > }
      >
      > // Empty (but not invalid) JSON response
      > if(oResponse.indexOf("{}") === 0) {
      > break;
      > }
      >
      > // Turn the string into an object literal...
      > // ...eval is necessary here
      > var jsonObjRaw = eval("(" + oResponse + ")");
      > if(!jsonObjRaw) {
      > bError = true;
      > break;
      > }
      >
      > // Grab the object member that contains an array
      > of all reponses...
      > // ...eval is necessary here since aSchema[0] is
      > of unknown depth
      > jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
      > }
      > catch(e) {
      > bError = true;
      > break;
      > }
      > }
      >
      > if(!jsonList) {
      > bError = true;
      > break;
      > }
      >
      > // Loop through the array of all responses...
      > for(var i = jsonList.length-1; i >= 0 ; i--) {
      > var aResultItem = [];
      > var jsonResult = jsonList[i];
      > // ...and loop through each data field value of each
      > response
      > for(var j = aSchema.length-1; j >= 1 ; j--) {
      > // ...and capture data into an array mapped
      > according to the schema...
      >
      > var dataFieldValue = jsonResult[aSchema[j]];
      > if(!dataFieldValue) {
      > dataFieldValue = "";
      > }
      > //doLog(dataFieldValue);
      > aResultItem.unshift(dataFieldValue);
      > }
      > // Capture the array of data field values in an array
      > of results
      > aResults.unshift(aResultItem);
      > }
      > break;
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > --- In ydn-javascript@yahoogroups.com, "THECREW" <jim@> wrote:
      > >
      > > Trying to get multiple results from the return. They show up in the
      > > returned json format
      > >
      > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
      > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
      > >
      > > But once I try to format the results it will only return the first
      > > location of the array.
      > >
      > >
      > >
      > >
      > >
      >
      ///////////////////////////////////////////////////////////////////////////
      > > // Instantiate second data source and define schema as an array:
      > >
      >
      ///////////////////////////////////////////////////////////////////////////
      > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
      > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
      > > oACDS2.queryMatchContains = true;
      > > oACDS2.scriptQueryAppend =
      > > "output=json&returnto=AssignedTo&callback=wsresults"; // Needed
      for YWS
      > >
      > > // Instantiate auto complete
      > > oAutoComp2 = new
      > > YAHOO.widget.AutoComplete('AssignedTo','AssignedToReturn', oACDS2);
      > >
      > > oAutoComp2.formatResult = function(oResultItem, sQuery) {
      > >
      > > alert(oResultItem[0]);
      > >
      > > // This was defined by the schema array of the data source
      > > var sEmployeeID = oResultItem[0];
      > > //var sFirstName = oResultItem[1];
      > > //var sMarkup = sFirstName + sEmployeeId;
      > > var sMarkup = sEmployeeID;
      > > return (sMarkup);
      > > }
      > >
      >
    • tony_bibbs
      Jenny, Can you please send a complete file with the patch in it? I ve got the same problem but seem to be battling JS errors and I just assume avoid the hassle
      Message 2 of 7 , Jul 7, 2006
      • 0 Attachment
        Jenny,

        Can you please send a complete file with the patch in it? I've got the
        same problem but seem to be battling JS errors and I just assume avoid
        the hassle of debugging it if you have a working copy handy.

        Thanks in advance,

        --Tony

        --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@...> wrote:
        >
        > Hi Jim,
        >
        > This is a bug that has been fixed in the next release. Until then,
        > here's a code snippet that should give you a workaround. Replace the
        > JSON the switch block in the XHR DataSource's parseResponse() method
        > witht he following. Let me know how this works out for you -- I hope
        > it helps!
        >
        > Jenny
        >
        >
        > case this.TYPE_JSON:
        > var jsonList;
        > if(window.JSON) {
        > // Use the JSON utility if available
        > var jsonObjParsed = JSON.parse(oResponse);
        > if(!jsonObjParsed) {
        > bError = true;
        > break;
        > }
        > else {
        > // eval is necessary here since aSchema[0] is of
        > unknown depth
        > jsonList = eval("jsonObjParsed." + aSchema[0]);
        > }
        > }
        > else {
        > // Parse the JSON response as a string
        > try {
        > // Trim leading spaces
        > while (oResponse.substring(0,1) == " ") {
        > oResponse = oResponse.substring(1,
        > oResponse.length);
        > }
        >
        > // Invalid JSON response
        > if(oResponse.indexOf("{") < 0) {
        > bError = true;
        > break;
        > }
        >
        > // Empty (but not invalid) JSON response
        > if(oResponse.indexOf("{}") === 0) {
        > break;
        > }
        >
        > // Turn the string into an object literal...
        > // ...eval is necessary here
        > var jsonObjRaw = eval("(" + oResponse + ")");
        > if(!jsonObjRaw) {
        > bError = true;
        > break;
        > }
        >
        > // Grab the object member that contains an array
        > of all reponses...
        > // ...eval is necessary here since aSchema[0] is
        > of unknown depth
        > jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
        > }
        > catch(e) {
        > bError = true;
        > break;
        > }
        > }
        >
        > if(!jsonList) {
        > bError = true;
        > break;
        > }
        >
        > // Loop through the array of all responses...
        > for(var i = jsonList.length-1; i >= 0 ; i--) {
        > var aResultItem = [];
        > var jsonResult = jsonList[i];
        > // ...and loop through each data field value of each
        > response
        > for(var j = aSchema.length-1; j >= 1 ; j--) {
        > // ...and capture data into an array mapped
        > according to the schema...
        >
        > var dataFieldValue = jsonResult[aSchema[j]];
        > if(!dataFieldValue) {
        > dataFieldValue = "";
        > }
        > //doLog(dataFieldValue);
        > aResultItem.unshift(dataFieldValue);
        > }
        > // Capture the array of data field values in an array
        > of results
        > aResults.unshift(aResultItem);
        > }
        > break;
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > --- In ydn-javascript@yahoogroups.com, "THECREW" <jim@> wrote:
        > >
        > > Trying to get multiple results from the return. They show up in the
        > > returned json format
        > >
        > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
        > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
        > >
        > > But once I try to format the results it will only return the first
        > > location of the array.
        > >
        > >
        > >
        > >
        > >
        >
        ///////////////////////////////////////////////////////////////////////////
        > > // Instantiate second data source and define schema as an array:
        > >
        >
        ///////////////////////////////////////////////////////////////////////////
        > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
        > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
        > > oACDS2.queryMatchContains = true;
        > > oACDS2.scriptQueryAppend =
        > > "output=json&returnto=AssignedTo&callback=wsresults"; // Needed
        for YWS
        > >
        > > // Instantiate auto complete
        > > oAutoComp2 = new
        > > YAHOO.widget.AutoComplete('AssignedTo','AssignedToReturn', oACDS2);
        > >
        > > oAutoComp2.formatResult = function(oResultItem, sQuery) {
        > >
        > > alert(oResultItem[0]);
        > >
        > > // This was defined by the schema array of the data source
        > > var sEmployeeID = oResultItem[0];
        > > //var sFirstName = oResultItem[1];
        > > //var sMarkup = sFirstName + sEmployeeId;
        > > var sMarkup = sEmployeeID;
        > > return (sMarkup);
        > > }
        > >
        >
      • THECREW
        Jenny, Yes I would like a copy of that to. I still can not get it to return more then first result. Thanks Jim
        Message 3 of 7 , Jul 7, 2006
        • 0 Attachment
          Jenny,

          Yes I would like a copy of that to. I still can not get it to return
          more then first result.

          Thanks
          Jim
          --- In ydn-javascript@yahoogroups.com, "tony_bibbs" <tony@...> wrote:
          >
          > Jenny,
          >
          > Can you please send a complete file with the patch in it? I've got the
          > same problem but seem to be battling JS errors and I just assume avoid
          > the hassle of debugging it if you have a working copy handy.
          >
          > Thanks in advance,
          >
          > --Tony
          >
          > --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@> wrote:
          > >
          > > Hi Jim,
          > >
          > > This is a bug that has been fixed in the next release. Until then,
          > > here's a code snippet that should give you a workaround. Replace the
          > > JSON the switch block in the XHR DataSource's parseResponse() method
          > > witht he following. Let me know how this works out for you -- I hope
          > > it helps!
          > >
          > > Jenny
          > >
          > >
          > > case this.TYPE_JSON:
          > > var jsonList;
          > > if(window.JSON) {
          > > // Use the JSON utility if available
          > > var jsonObjParsed = JSON.parse(oResponse);
          > > if(!jsonObjParsed) {
          > > bError = true;
          > > break;
          > > }
          > > else {
          > > // eval is necessary here since aSchema[0] is of
          > > unknown depth
          > > jsonList = eval("jsonObjParsed." + aSchema[0]);
          > > }
          > > }
          > > else {
          > > // Parse the JSON response as a string
          > > try {
          > > // Trim leading spaces
          > > while (oResponse.substring(0,1) == " ") {
          > > oResponse = oResponse.substring(1,
          > > oResponse.length);
          > > }
          > >
          > > // Invalid JSON response
          > > if(oResponse.indexOf("{") < 0) {
          > > bError = true;
          > > break;
          > > }
          > >
          > > // Empty (but not invalid) JSON response
          > > if(oResponse.indexOf("{}") === 0) {
          > > break;
          > > }
          > >
          > > // Turn the string into an object literal...
          > > // ...eval is necessary here
          > > var jsonObjRaw = eval("(" + oResponse + ")");
          > > if(!jsonObjRaw) {
          > > bError = true;
          > > break;
          > > }
          > >
          > > // Grab the object member that contains an array
          > > of all reponses...
          > > // ...eval is necessary here since aSchema[0] is
          > > of unknown depth
          > > jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
          > > }
          > > catch(e) {
          > > bError = true;
          > > break;
          > > }
          > > }
          > >
          > > if(!jsonList) {
          > > bError = true;
          > > break;
          > > }
          > >
          > > // Loop through the array of all responses...
          > > for(var i = jsonList.length-1; i >= 0 ; i--) {
          > > var aResultItem = [];
          > > var jsonResult = jsonList[i];
          > > // ...and loop through each data field value of each
          > > response
          > > for(var j = aSchema.length-1; j >= 1 ; j--) {
          > > // ...and capture data into an array mapped
          > > according to the schema...
          > >
          > > var dataFieldValue = jsonResult[aSchema[j]];
          > > if(!dataFieldValue) {
          > > dataFieldValue = "";
          > > }
          > > //doLog(dataFieldValue);
          > > aResultItem.unshift(dataFieldValue);
          > > }
          > > // Capture the array of data field values in an array
          > > of results
          > > aResults.unshift(aResultItem);
          > > }
          > > break;
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > > --- In ydn-javascript@yahoogroups.com, "THECREW" <jim@> wrote:
          > > >
          > > > Trying to get multiple results from the return. They show up in the
          > > > returned json format
          > > >
          > > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
          > > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
          > > >
          > > > But once I try to format the results it will only return the first
          > > > location of the array.
          > > >
          > > >
          > > >
          > > >
          > > >
          > >
          >
          ///////////////////////////////////////////////////////////////////////////
          > > > // Instantiate second data source and define schema as an array:
          > > >
          > >
          >
          ///////////////////////////////////////////////////////////////////////////
          > > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
          > > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
          > > > oACDS2.queryMatchContains = true;
          > > > oACDS2.scriptQueryAppend =
          > > > "output=json&returnto=AssignedTo&callback=wsresults"; // Needed
          > for YWS
          > > >
          > > > // Instantiate auto complete
          > > > oAutoComp2 = new
          > > > YAHOO.widget.AutoComplete('AssignedTo','AssignedToReturn', oACDS2);
          > > >
          > > > oAutoComp2.formatResult = function(oResultItem, sQuery) {
          > > >
          > > > alert(oResultItem[0]);
          > > >
          > > > // This was defined by the schema array of the data source
          > > > var sEmployeeID = oResultItem[0];
          > > > //var sFirstName = oResultItem[1];
          > > > //var sMarkup = sFirstName + sEmployeeId;
          > > > var sMarkup = sEmployeeID;
          > > > return (sMarkup);
          > > > }
          > > >
          > >
          >
        • Tony Bibbs
          I guess for me it doesn t matter. I just changed my server look-ups to output XML for now as this isn t an issue with the XML datasource. Works fine now...
          Message 4 of 7 , Jul 7, 2006
          • 0 Attachment
            I guess for me it doesn't matter. I just changed my server look-ups to
            output XML for now as this isn't an issue with the XML datasource.
            Works fine now...

            --Tony

            tony_bibbs wrote:
            >
            >
            > Jenny,
            >
            > Can you please send a complete file with the patch in it? I've got the
            > same problem but seem to be battling JS errors and I just assume avoid
            > the hassle of debugging it if you have a working copy handy.
            >
            > Thanks in advance,
            >
            > --Tony
          • jennykhan
            Hi Jim, The fix is available in version 0.11, which has just been released. Be sure to check the README file if you are going to be upgrading an existing
            Message 5 of 7 , Jul 12, 2006
            • 0 Attachment
              Hi Jim,

              The fix is available in version 0.11, which has just been released. Be
              sure to check the README file if you are going to be upgrading an
              existing implementation.

              Thanks,
              Jenny




              --- In ydn-javascript@yahoogroups.com, "THECREW" <jim@...> wrote:
              >
              > Jenny,
              >
              > Yes I would like a copy of that to. I still can not get it to return
              > more then first result.
              >
              > Thanks
              > Jim
              > --- In ydn-javascript@yahoogroups.com, "tony_bibbs" <tony@> wrote:
              > >
              > > Jenny,
              > >
              > > Can you please send a complete file with the patch in it? I've got the
              > > same problem but seem to be battling JS errors and I just assume avoid
              > > the hassle of debugging it if you have a working copy handy.
              > >
              > > Thanks in advance,
              > >
              > > --Tony
              > >
              > > --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@> wrote:
              > > >
              > > > Hi Jim,
              > > >
              > > > This is a bug that has been fixed in the next release. Until then,
              > > > here's a code snippet that should give you a workaround. Replace the
              > > > JSON the switch block in the XHR DataSource's parseResponse() method
              > > > witht he following. Let me know how this works out for you -- I hope
              > > > it helps!
              > > >
              > > > Jenny
              > > >
              > > >
              > > > case this.TYPE_JSON:
              > > > var jsonList;
              > > > if(window.JSON) {
              > > > // Use the JSON utility if available
              > > > var jsonObjParsed = JSON.parse(oResponse);
              > > > if(!jsonObjParsed) {
              > > > bError = true;
              > > > break;
              > > > }
              > > > else {
              > > > // eval is necessary here since aSchema[0] is of
              > > > unknown depth
              > > > jsonList = eval("jsonObjParsed." + aSchema[0]);
              > > > }
              > > > }
              > > > else {
              > > > // Parse the JSON response as a string
              > > > try {
              > > > // Trim leading spaces
              > > > while (oResponse.substring(0,1) == " ") {
              > > > oResponse = oResponse.substring(1,
              > > > oResponse.length);
              > > > }
              > > >
              > > > // Invalid JSON response
              > > > if(oResponse.indexOf("{") < 0) {
              > > > bError = true;
              > > > break;
              > > > }
              > > >
              > > > // Empty (but not invalid) JSON response
              > > > if(oResponse.indexOf("{}") === 0) {
              > > > break;
              > > > }
              > > >
              > > > // Turn the string into an object literal...
              > > > // ...eval is necessary here
              > > > var jsonObjRaw = eval("(" + oResponse + ")");
              > > > if(!jsonObjRaw) {
              > > > bError = true;
              > > > break;
              > > > }
              > > >
              > > > // Grab the object member that contains an array
              > > > of all reponses...
              > > > // ...eval is necessary here since aSchema[0] is
              > > > of unknown depth
              > > > jsonList = eval("(jsonObjRaw." +
              aSchema[0]+")");
              > > > }
              > > > catch(e) {
              > > > bError = true;
              > > > break;
              > > > }
              > > > }
              > > >
              > > > if(!jsonList) {
              > > > bError = true;
              > > > break;
              > > > }
              > > >
              > > > // Loop through the array of all responses...
              > > > for(var i = jsonList.length-1; i >= 0 ; i--) {
              > > > var aResultItem = [];
              > > > var jsonResult = jsonList[i];
              > > > // ...and loop through each data field value of each
              > > > response
              > > > for(var j = aSchema.length-1; j >= 1 ; j--) {
              > > > // ...and capture data into an array mapped
              > > > according to the schema...
              > > >
              > > > var dataFieldValue = jsonResult[aSchema[j]];
              > > > if(!dataFieldValue) {
              > > > dataFieldValue = "";
              > > > }
              > > > //doLog(dataFieldValue);
              > > > aResultItem.unshift(dataFieldValue);
              > > > }
              > > > // Capture the array of data field values in an
              array
              > > > of results
              > > > aResults.unshift(aResultItem);
              > > > }
              > > > break;
              > > >
              > > >
              > > >
              > > >
              > > >
              > > >
              > > >
              > > >
              > > >
              > > > --- In ydn-javascript@yahoogroups.com, "THECREW" <jim@> wrote:
              > > > >
              > > > > Trying to get multiple results from the return. They show up
              in the
              > > > > returned json format
              > > > >
              > > > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
              > > > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
              > > > >
              > > > > But once I try to format the results it will only return the first
              > > > > location of the array.
              > > > >
              > > > >
              > > > >
              > > > >
              > > > >
              > > >
              > >
              >
              ///////////////////////////////////////////////////////////////////////////
              > > > > // Instantiate second data source and define schema as an array:
              > > > >
              > > >
              > >
              >
              ///////////////////////////////////////////////////////////////////////////
              > > > > oACDS2 = new YAHOO.widget.DS_XHR("../includes/ysearch_proxy.php",
              > > > > ["ResultSet.Result", "EmployeeID","FirstName","LastName" ]);
              > > > > oACDS2.queryMatchContains = true;
              > > > > oACDS2.scriptQueryAppend =
              > > > > "output=json&returnto=AssignedTo&callback=wsresults"; // Needed
              > > for YWS
              > > > >
              > > > > // Instantiate auto complete
              > > > > oAutoComp2 = new
              > > > > YAHOO.widget.AutoComplete('AssignedTo','AssignedToReturn',
              oACDS2);
              > > > >
              > > > > oAutoComp2.formatResult = function(oResultItem, sQuery) {
              > > > >
              > > > > alert(oResultItem[0]);
              > > > >
              > > > > // This was defined by the schema array of the data source
              > > > > var sEmployeeID = oResultItem[0];
              > > > > //var sFirstName = oResultItem[1];
              > > > > //var sMarkup = sFirstName + sEmployeeId;
              > > > > var sMarkup = sEmployeeID;
              > > > > return (sMarkup);
              > > > > }
              > > > >
              > > >
              > >
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.