Saturday, 20 May 2017

JADE, Nodejs and JSON data rendering

I am trying to render a table at my index.jade page using arrays which are send using dates and product_count from index.js page.

        res.render('index', {
        title: 'Product Count (last 7 days)',
        keyy : dates,
        results: product_count
        });

At my index.jade page it is showing as :click here

From the table, In each tablecells, the data is printing like this :

Amul Butter salted=2,Curd Milky Mist 200 gms=9,Curd Milky Mist 500 gms=15,Idli and Dosa Batter ID 1 Kg=12,Towness Baby Corn Peeled=4,Towness Banana Green Regular Semi Ripe=3,Towness Banana Yalakki Semi Ripe=1,Towness Bitter Gourd Medium=1,Towness Bottle Gourd Small=1,Towness Brinjal Long Green Medium=1,Towness Celery=2,Towness Chow Chow Medium Grade A=1,Towness European cucumber=7,Towness Garlic Peeled=1,

What I want to print this data , each separated by "," in different row, like this:

Amul Butter salted=2
Curd Milky Mist 200 gms=9
Curd Milky Mist 500 gms=15
Idli and Dosa Batter ID 1 Kg=12
Towness Baby Corn Peeled=4
Towness Banana Green Regular Semi Ripe=3
Towness Banana Yalakki Semi Ripe=1
Towness Bitter Gourd Medium=1
Towness Bottle Gourd Small=1
Towness Brinjal Long Green Medium=1
Towness Celery=2
Towness Chow Chow Medium Grade A=1
Towness European cucumber=7
Towness Garlic Peeled=1

I am pasting my array here, just help me how get each value in newline thats it.

dates = [ 'May 17 2017', 'May 18 2017', 'May 19 2017', 'May 20 2017' ]

product_count = [ 'Amul Butter salted=2,Curd Milky Mist 200 gms=9,Curd Milky Mist 500 gms=15,Idli and Dosa Batter ID 1 Kg=12,Towness Baby Corn Peeled=4,Towness Banana Green Regular Semi Ripe=3,Towness Banana Yalakki Semi Ripe=1,Towness Bitter Gourd Medium=1,Towness Bottle Gourd Small=1,Towness Brinjal Long Green Medium=1,Towness Celery=2,Towness Chow Chow Medium Grade A=1,Towness European cucumber=7,Towness Garlic Peeled=1,Towness Lemon  Medium =1,Towness Lettuce (Leafy Green)=5,Towness Mangalore Cucumber Medium=8,Towness Mint Leaves (Pudina Bunch)=2,Towness Musk Melon Stripes=1,Towness Onion Medium=1,Towness Papaya Raw=2,Towness Pumpkin Disco Town=3,Towness Raw Banana=1,Towness Red Radish (Long)=1,Towness Sambhar Onion=6,Towness Tomato Semi Ripe (Medium)=1',
  'Amul Butter salted=5,Curd Milky Mist 500 gms=11,Eggs Town  6 in 1=1,Paneer Nandini=2,Towness Banana Nendran Kerala Ripe=1,Towness Banana Yalakki Semi Ripe=10,Towness Bitter Gourd Medium=1,Towness Bread Multigrain Town 400 Gms=2,Towness Cluster beans=1,Towness Coriander Leaves=1,Towness European cucumber=1,Towness Ginger=1,Towness Lettuce (Ice Burg)=1,Towness Long Beans=2,Towness Mint Leaves (Pudina Bunch)=1,Towness Pumpkin Disco Town=1,Towness Red Cabbage=1,Towness Sambhar Onion=2',
  'Curd Milky Mist 500 gms=1,Hair Oil Coconut Parachute 250 Ml=1,Real Mixed Fruit 1 Ltr=1,Soda Lehar Evervess 500 Ml=1,Towness Alasande kai=1,Towness Banana Yalakki Semi Ripe=1,Towness Bread Multigrain Town 400 Gms=1,Towness Chutney Coconut Spicy=2,Towness Ginger=1,Towness Ladies Finger=1,Towness Nool Kol =1,Towness Sambhar Onion=1,Towness Tomato Semi Ripe (Medium)=1',
  'Naan Tawa (Half cooked) Town 5 Nos=1,Paneer Milky Mist 200 g=1,Real Mixed Fruit 1 Ltr=2,Towness Bread Kulcha=1,Towness Chikki Flax Seeds=2,Towness Chikki Melon seeds( Magaz)=2,Towness Coriander Leaves=7,Towness French Beans Grade A=6,Towness Ladies Finger=1,Towness Lemon  Medium =3,Towness Onion Medium=2,Towness Red Cabbage=1,Towness Sambhar Onion=1,Towness Tender Coconut=1,Towness Tomato Ripe (Medium)=1,Towness Tomato Semi Ripe (Medium)=1' ]

Please help me. If you have any doubt just mention it below. I am totally online from now.



via Rahul Sharma

No comments:

Post a Comment