0

for my sencha touch app my json data like this,

{
  "type": "FeatureCollection",
  "features": [
{
  "type": "Feature",
  "id": "rodos_business_pois.1",
  "geometry": {
    "type": "Point",
    "coordinates": [
      28.21962354993591,
      36.452844361147314
    ]
  },
  "geometry_name": "geom",
  "properties": {
    "id": null,
    "business_p": "AQUARIOUM",
    "name_owner": null,
    "surname_ow": null,
    "middle_nam": null,
    "category_n": "BAR",
    "category_c": "020200",
    "category_1": null,
    "category_2": null,
    "category_3": null,
    "address": "28 GRIVA GEORGIOU",
    "street_nam": "ÃÑÉÂÁ ÃÅÙÑÃÉÏÕ",
    "number": "28",
    "postcode": null,
    "places_en_": "RODOS",
    "f16": 1,
    "f17": 0,
    "tel": 2.24102778E9,
    "fax": 0,
    "mob": 0,
    "email": null,
    "url": null,
    "places_gr": null,
    "places_en": null
  }
},
{
  "type": "Feature",
  "id": "rodos_business_pois.2",
  "geometry": {
    "type": "Point",
    "coordinates": [
      28.225417523605692,
      36.436470953176716
    ]
  },
  "geometry_name": "geom",
  "properties": {
    "id": null,
    "business_p": "ZIGOS",
    "name_owner": null,
    "surname_ow": null,
    "middle_nam": null,
    "category_n": "BAR",
    "category_c": "020200",
    "category_1": null,
    "category_2": null,
    "category_3": null,
    "address": "89 KAZOULI STEFANOU",
    "street_nam": "ÊÁÆÏÕËÇ ÓÔÅÖÁÍÏÕ",
    "number": "89",
    "postcode": null,
    "places_en_": "RODOS",
    "f16": 1,
    "f17": 0,
    "tel": 2.24103987E9,
    "fax": 0,
    "mob": 0,
    "email": null,
    "url": null,
    "places_gr": null,
    "places_en": null
  }
},
{
  "type": "Feature",
  "id": "rodos_business_pois.3",
  "geometry": {
    "type": "Point",
    "coordinates": [
      28.223100266167258,
      36.45251556942936
    ]
  },
  "geometry_name": "geom",
  "properties": {
    "id": null,
    "business_p": "LA ROSA FASHION BAR",
    "name_owner": null,
    "surname_ow": null,
    "middle_nam": null,
    "category_n": "BAR",
    "category_c": "020200",
    "category_1": null,
    "category_2": null,
    "category_3": null,
    "address": "4 PAPANIKOLAOU GEORGIOU",
    "street_nam": "ÐÁÐÁÍÉÊÏËÁÏÕ ÃÅÙÑÃÉÏÕ",
    "number": "4",
    "postcode": null,
    "places_en_": "RODOS",
    "f16": 1,
    "f17": 0,
    "tel": 2.2410974E9,
    "fax": 0,
    "mob": 0,
    "email": null,
    "url": null,
    "places_gr": null,
    "places_en": null
  }
},
{
  "type": "Feature",
  "id": "rodos_business_pois.4",
  "geometry": {
    "type": "Point",
    "coordinates": [
      28.226588152300117,
      36.43403310824089
    ]
  },
  "geometry_name": "geom",
  "properties": {
    "id": null,
    "business_p": "G-NET",
    "name_owner": null,
    "surname_ow": null,
    "middle_nam": null,
    "category_n": "RESTAURANT",
    "category_c": "020100",
    "category_1": null,
    "category_2": null,
    "category_3": null,
    "address": "135 AGIAS ANASTASIAS",
    "street_nam": "ÁÃÉÁÓ ÁÍÁÓÔÁÓÉÁÓ",
    "number": "135",
    "postcode": null,
    "places_en_": "RODOS",
    "f16": 1,
    "f17": 0,
    "tel": 2.2410351E9,
    "fax": 0,
    "mob": 0,
    "email": null,
    "url": null,
    "places_gr": null,
    "places_en": null
  }
},
{
  "type": "Feature",
  "id": "rodos_business_pois.5",
  "geometry": {
    "type": "Point",
    "coordinates": [
      28.215719877096184,
      36.43079419827729
    ]
  },
  "geometry_name": "geom",
  "properties": {
    "id": null,
    "business_p": "ANDRMEDA LOUNGE BAR",
    "name_owner": null,
    "surname_ow": null,
    "middle_nam": null,
    "category_n": "CAFE",
    "category_c": "020100",
    "category_1": null,
    "category_2": null,
    "category_3": null,
    "address": "4 PAPANDREOU GEORGIOU",
    "street_nam": "ÐÁÐÁÍÄÑÅÏÕ ÃÅÙÑÃÉÏÕ",
    "number": "4",
    "postcode": null,
    "places_en_": "RODOS",
    "f16": 1,
    "f17": 0,
    "tel": 2.2410974E9,
    "fax": 2.2410975E9,
    "mob": 0,
    "email": null,
    "url": null,
    "places_gr": null,
    "places_en": null
  }
},
{
  "type": "Feature",
  "id": "rodos_business_pois.6",
  "geometry": {
    "type": "Point",
    "coordinates": [
      28.226209613062103,
      36.43806195312573
    ]
  },
  "geometry_name": "geom",
  "properties": {
    "id": null,
    "business_p": "DOLCE CAFE",
    "name_owner": null,
    "surname_ow": null,
    "middle_nam": null,
    "category_n": "RESTAURANT",
    "category_c": "020100",
    "category_1": null,
    "category_2": null,
    "category_3": null,
    "address": "14 DODEKANISIAKIS NEOLEAS",
    "street_nam": "ÄÙÄÅÊÁÍÇÓÉÁÊÇÓ ÍÅÏËÁÉÁÓ",
    "number": "14",
    "postcode": null,
    "places_en_": "RODOS",
    "f16": 1,
    "f17": 0,
    "tel": 2.24102988E9,
    "fax": 0,
    "mob": 0,
    "email": null,
    "url": null,
    "places_gr": null,
    "places_en": null
  }
},
.......
.......
....... and so on..

i can parse all these data at a time using sencha touch json reader, but now i want to parse this data by category wise, means at a time i want to parse all those data which have category like BAR or CAFE or RESTAURANT.

any help will be appericiated. Thanks in advance.

2
  • you have to read all and filter it, or else modify the API so that you pass the specific category and get the JSON accordingly Commented Mar 28, 2013 at 11:41
  • can you suggest good filter example or suggestion about how to modify API ? Commented Mar 28, 2013 at 11:53

1 Answer 1

1

This is how you filter the store

store.filterBy(function(record, id){
    var cat = record.get('category_n');
    if(cat == 'BAR' || cat == 'CAFE' || cat == 'RESTAURANT'){
        return true;
    }else{
        return false;
    }
});

This will iterate each record and will pass it in function, so if you want to check for category_n

EDIT: make sure you clear the store filter next time you load data into the store by

store.clearFilter();
Sign up to request clarification or add additional context in comments.

15 Comments

thanks.., in record field i can get all data, but stuck there, i can't go ahead. can you give me some more explanation ?
Record will contain element from ur json array and it will iterate one by one.. from your recordmatch the ccondition on which u want to filter.. if u return true that element will be available in ur store if u return false then it will be removed from store...
i can't get it, becoz it throwing error during getting properties using record.get('properties'). and throwing error like this, TypeError: 'undefined' is not an object (evaluating 'prop.get')
thats more reasonable and expected, console.log(record); and check if properties is in there? i'm expecting it should have type and feature
can u please paste whole json so that it would be good to figure out coz the json you have posted is incomplete, also the reader you using in proxy to read this, may be we have to put one more filter on first place
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.