Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8515915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:16:37+00:00 2026-06-11T05:16:37+00:00

i am trying to use the YUI to display a table. Using the following

  • 0

i am trying to use the YUI to display a table. Using the following example

YAHOO.example.Data = {
        bookorders: [
            {id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"},
            {id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"},
            {id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"},
            {id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}
        ]
    }

    YAHOO.example.Basic = function() {
        var myColumnDefs = [
            {key:"id", sortable:true, resizeable:true},
            {key:"date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true},
            {key:"quantity", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true},
            {key:"amount", formatter:YAHOO.widget.DataTable.formatCurrency, sortable:true, resizeable:true},
            {key:"title", sortable:true, resizeable:true}
        ];

        var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.bookorders);
        myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
        myDataSource.responseSchema = {
            fields: ["id","date","quantity","amount","title"]
        };

        var myDataTable = new YAHOO.widget.DataTable("basic",
                myColumnDefs, myDataSource, {caption:"DataTable Caption"});

        return {
            oDS: myDataSource,
            oDT: myDataTable
        };
    }();

but instead of using the bookorders Data, I queried a result from the database using a esri.tasks.QueryTask

so i got to iterate through the data i got to populate the bookorders json array.

for (var i=0, il=results_books.features.length; i<il; i++) {
     var featureAttributes = results_books.features[i].attributes;
         var string = " id : \"" + results_books.features[i].attributes[0] + "\",";
         var string = string + " date : \"" + results_books.features[i].attributes[1] + "\",";
         var string = string + " quantity: \"" + results_books.features[i].attributes[2] + "\",";
         var string = string + " amount: \"" + results_books.features[i].attributes[3] + "\",";
         var string = string + " title: \"" + results_books.features[i].attributes[4] + "\"";

}

but how do i push the string into the JSON array and is the way to read the attributes correct?

EDIT: added the commas to the string

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:16:39+00:00Added an answer on June 11, 2026 at 5:16 am

    Just use an object literal rather than building up a string:

    for (var i=0, il=results_books.features.length; i<il; i++) {
         var featureAttributes = results_books.features[i].attributes;
         var book = {
            "id" : featureAttributes[0],
            "date" : featureAttributes[1],
            "quantity" : featureAttributes[2],
            "amount" : featureAttributes[3],
            "title" : featureAttributes[4]
          };
          // push into array   
    }
    

    No need to use an intermediary string, create a full out object right away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the YUI datatable to display data from a JSON
I'm trying to display the following JSON object using YUI DataTable. I was able
I'm trying to use YUI compressor in a maven goal, but I'm pretty new
http://developer.yahoo.com/yui/datasource/#events I'm trying to use the responseParseEvent but I don't know how to hook
Trying to use autocomplete functionality of YUI, we ran into the fact that it's
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
I'm trying to use YUI compressor for .NET as an MSBUILD event $(MSBuildBinPath)\msbuild.exe $(ProjectDir)MSBuild\MSBuildSettings.xml
I'm trying to use YUI to validate a radio button group on form submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.