Can not show CSV data from the file.

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Can not show CSV data from the file.

DojoNovice
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Can not show CSV data from the file. I see only three dots (...) for every cell. What is wrong?

Here is my code.


<!DOCTYPE html>
<html>
  <head>
    <title>dojox/grid/DataGrid with CSV file </title>
    <meta charset="utf-8"/>
    <link rel="StyleSheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.0/dijit/themes/claro/claro.css"/>
    <link rel="StyleSheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.0/dojox/grid/resources/claroGrid.css"/>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.0/dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad:true, async:1"></script>
  </head>

  <body class="claro">

    <article data-dojo-type="dojox.data.CsvStore" data-dojo-props="url : 'data.csv'" data-dojo-id="display">
    </article>
                                                   
   
First NameLast Name

    <script> require(["dojo", "dojo/parser", "dojox/data/CsvStore", "dojox/grid/DataGrid"], function(dojo) { dojo.ready(function() { }); }); </script>  </body>
</html>

I have created this example programmatically too. If I used url to csv file, data did not show. If I used JS object inside javascript section, data were displayed.

I have inspected it and data are in store. If I use setStore() method, it does not bind the data.


    <div id="grid" data-dojo-type="dojox.grid.EnhancedGrid"
    data-dojo-props="query:{}, autoHeight : true, autoWidth : true"></div>
   
   
    <script>
      require(["dojo", "dojo/parser", "dojox/data/CsvStore", "dojox/grid/DataGrid"], function(dojo) {
        dojo.ready(function() {

         var grid = dijit.byId("grid");

          var Csv_store = new dojox.data.CsvStore({
            url : "data.csv"
          });

          var layout = [[{
            field : "firstname",
            name : "First Name",

          }, {
            field : "lastname",
            name : "Last Name"

          }, {
            field : "age",
            name : "Age"

          }]];
         
          grid.setStructure(layout);
          grid.setStore(Csv_store);

        });
      });

Reply | Threaded
Open this post in threaded view
|

Re: Can not load CSV data from file.

madproffessor
This post has NOT been accepted by the mailing list yet.
You have to create a new instance of a store like this:
var display = new dojox.data.CsvStore({url:"data.csv"});

and check the file permissions of data.csv
Reply | Threaded
Open this post in threaded view
|

Re: Can not load CSV data from file.

DojoNovice
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hi

Thank you for your response.

Same example with JSON works properly. With XML I can read only first row. I want use declarative method not programmatic. Your advice is programmatic. I have all permissions. There is not problem.
Reply | Threaded
Open this post in threaded view
|

Re: Can not load CSV data from file.

subirkumarsao
Your code is working fine with me.

Dojo uses AJAX to load the csv file. I hope you are using a webserver.

Share the csv file. Let me check with that too.

cheers.
Reply | Threaded
Open this post in threaded view
|

Re: Can not load CSV data from file.

DojoNovice
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Yes, I am using webserver Apache. I have tested it with 2 Apache servers and I didnt see data only ...  (three dots instead items).

Console output:

XHR finished loading: "xxxxx.csv".


I have problem with headers too. If I use


      .dojoxGridMasterHeader {
        display : none !important;
      }

or

    .dojoxGridHeader {
        display : none !important;
      }

I dont see grid only grid lines deformation.

I am using chrome browser. But it is same with Opera.
Reply | Threaded
Open this post in threaded view
|

Re: Can not load CSV data from file.

DojoNovice
This post has NOT been accepted by the mailing list yet.
In reply to this post by subirkumarsao
Please, see introduction (first post). It was augmented.
Reply | Threaded
Open this post in threaded view
|

Re: Can not load CSV data from file.

DojoNovice
This post has NOT been accepted by the mailing list yet.
This post was updated on .
In reply to this post by subirkumarsao
For subirkumarsao

My csv file demo.


Data 1, Data 2
Data 3, Data 4
Data 5, Data 6



please post your sample.


I made testcases with Dojo 1.6 several months ago and it worked fine.
Reply | Threaded
Open this post in threaded view
|

Re: Can not load CSV data from file.

DojoNovice
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Done

I need to define first line with field names.

In this case:

Column1|Column2
Data 1|Data 2
Data 3|Data 4
Data 5|Data 6