1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    22
    Vote Rating
    1
    vipul30 is on a distinguished road

      0  

    Default Navigation View - won't push new view from list disclosure.

    Navigation View - won't push new view from list disclosure.


    I cannot get the onListDisclose to push a new view. Can someone please help? Here's the code in the controller.

    Ext.define('MyApp.controller.MyController1', {
    extend: 'Ext.app.Controller',


    config: {
    views: [
    'NavigStores'
    ],


    refs: {
    mymap: '#mymap',
    searchPanel: 'searchPanel',
    address: '#address',
    navig: {
    autoCreate: true,
    selector: '#navigStores',
    xtype: 'navigationview'
    }
    },


    control: {
    "map#mymap": {
    initialize: 'onMymapInitialize'
    },
    "searchfield#mysearchfield": {
    focus: 'onMysearchfieldFocus'
    },
    "#searchButton": {
    tap: 'onSearchButtonTap'
    },
    "#currentLocationBtn": {
    tap: 'onCurrentLocationBtnTap'
    },
    "#listViewBtn": {
    tap: 'onListViewBtnTap'
    },
    "list": {
    disclose: 'onListDisclose'
    }
    }
    },


    onMymapInitialize: function(component, options) {


    console.log("map initialzed");


    //var currentLocation = navigator.geolocation.getCurrentPosition();


    //console.log('currentLocation= ', currentLocation);


    var myStore = Ext.getStore("FacilityStore");


    var globalThis = this;


    var myMap = this.getMymap();


    console.log('myMap: ', myMap);




    navigator.geolocation.getCurrentPosition(
    function(position) {
    var initialLocation = new google.maps.LatLng(position.coords.latitude,
    position.coords.longitude);


    console.log("initialLocation= ", initialLocation);


    myMap.setMapCenter({latitude: position.coords.latitude,
    longitude: position.coords.longitude}
    );


    //var radius = .5;






    /*


    Ext.Ajax.request({


    url: 'http://localhost:8732/Service1/getfacilities',
    method: 'GET',
    params: initialLocation,




    success: function(form) {


    //console.log('form= ', form.responseText);
    var json = Ext.decode(form.responseText);
    console.log('json[0]= ', json[0]);


    myStore.setData(json);




    console.log('google map: ', myMap.getMap());


    var mapCenter = function(){
    var pnt = new google.maps.LatLng(myStore.getAt(5).get('lat'),
    myStore.getAt(5).get('lng'));
    myMap.getMap().setCenter(pnt);
    };


    myStore.each(function(record,id){
    var lat = record.get('lat');
    var lng = record.get('lng');


    var markerTitle = record.get('facilityName');


    var marker = new google.maps.Marker(
    {
    position: new google.maps.LatLng(lat, lng),
    map: myMap.getMap(),
    title: markerTitle
    }
    );


    var infoWindow = new google.maps.InfoWindow({
    content: record.get('facilityName')
    });


    google.maps.event.addListener(marker, 'click',
    function() {
    infoWindow.open(myMap.getMap(), marker);
    });


    });






    },
    failure: function(response, object) {
    console.log('response= ', response);
    console.log('object= ', object);
    Ext.Msg.alert('', 'Login Failed!');
    }
    });


    */
    },
    function() {
    console.log('could not get current position');
    }
    );






    var geo = this.getMymap().getGeo();














    },


    onMysearchfieldFocus: function(textfield, e, options) {
    console.log('search focus');


    if (!this.view) {
    this.view = Ext.create('MyApp.view.SearchPanel');
    }


    //this.view.setLoan(record);


    if (!this.view.getParent()) {
    Ext.Viewport.add(this.view);
    }


    this.view.show();




    },


    onSearchButtonTap: function(button, e, options) {


    var values = this.getSearchPanel().getValues(true);
    var myStore = Ext.getStore("FacilityStore");


    var markersArray = [];


    console.log('global marker: ', MyApp.globals.markersArray);


    // Remove everything from the store
    myStore.remove(myStore.getRange());


    console.log('values= ', values);


    Ext.Ajax.request({


    url: 'http://localhost:8732/Service1/searchrequest',
    method: 'GET',
    params: values,
    //timeout: 5000000,
    success: function(form) {


    console.log('form= ', form.responseText);


    if (form.responseText == '') {
    Ext.Msg.alert('', 'No Facilities Found', Ext.emptyFn);
    var pnl = Ext.getCmp('searchPanel');
    pnl.hide();
    return;
    }


    var json = Ext.decode(form.responseText);
    console.log('json[0]= ', json[0]);


    myStore.setData(json);


    var pnl = Ext.getCmp('searchPanel');
    pnl.hide();


    var myMap = Ext.getCmp('mymap');


    myMap.initialize(this);




    // Set the current location to the first item in search results
    if (myStore.totalCount !== 0) {
    myMap.setMapCenter({latitude: myStore.getAt(0).get('lat'),
    longitude: myStore.getAt(0).get('lng')}
    );
    }


    // Set zoom
    myMap.getMap().setZoom(12);




    // clear markers


    // Removes the overlays from the map, but keeps them in the array




    if (MyApp.globals.markersArray) {
    console.log('clearoverlay array', MyApp.globals.markersArray);
    for (i in MyApp.globals.markersArray) {


    MyApp.globals.markersArray[i].setMap(null);
    }
    }




    //function deleteOverlays() {
    if (MyApp.globals.markersArray) {
    console.log('delete array', MyApp.globals.markersArray);
    for (i in MyApp.globals.markersArray) {
    MyApp.globals.markersArray[i].setMap(null);
    }
    MyApp.globals.markersArray.length = 0;
    }
    // };


    myStore.each(function(record,id){
    var lat = record.get('lat');
    var lng = record.get('lng');


    var markerTitle = record.get('facilityName');


    var marker = new google.maps.Marker(
    {
    position: new google.maps.LatLng(lat, lng),
    map: myMap.getMap(),
    title: markerTitle
    }
    );


    MyApp.globals.markersArray.push(marker);


    var infoWindow = new google.maps.InfoWindow({
    content: record.get('facilityName')
    });


    google.maps.event.addListener(marker, 'click',
    function() {
    infoWindow.open(myMap.getMap(), marker);
    });






    });






    },
    failure: function(response, object) {
    console.log('response= ', response);
    console.log('object= ', object);
    Ext.Msg.alert('', 'No facilities found.');
    }
    });
    },


    onCurrentLocationBtnTap: function(button, e, options) {




    console.log('address: ', Ext.getCmp('address'));


    var address = Ext.getCmp('address');


    var geoCoder = new google.maps.Geocoder();




    var currentAddress;




    navigator.geolocation.getCurrentPosition(
    function(position) {
    var initialLocation = new google.maps.LatLng(position.coords.latitude,
    position.coords.longitude);


    geoCoder.geocode({'latLng': initialLocation}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    if (results[0]) {


    address.setValue(results[0].formatted_address);


    console.log('address: ', results[0].formatted_address);
    }
    } else {
    alert("Geocoder failed due to: " + status);
    }


    });


    console.log("initialLocation= ", initialLocation);
    console.log("position= ", position);






    },
    function() {
    console.log('could not get current position');
    }




    );
    console.log('currentAddress: ', currentAddress);
    },


    onListViewBtnTap: function(button, e, options) {
    // Show a list of results


    //if (!this.view) {
    this.view = Ext.create('MyApp.view.StoreList');
    //}


    //this.view.setLoan(record);


    //if (!this.view.getParent()) {
    Ext.Viewport.add(this.view);
    //}


    this.view.show();
    },


    onListDisclose: function(list, record, target, index, e, options) {
    console.log('onlistdisclose');


    console.log('record.facilityID= ', record.get('facilityID'));


    var myStore = Ext.getStore("InspectionsStore");






    var navigStores = this.getNavig();




    console.log('navigStores= ', this.getNavig());




    //console.log('refs= ', this.getRefs());


    // Remove everything from the store
    myStore.remove(myStore.getRange());


    Ext.Ajax.request({


    url: 'http://localhost:8732/Service1/getinspectionresults',
    method: 'GET',
    params: { facilityID: record.get('facilityID')},


    success: function(form) {


    //console.log('form= ', form.responseText);


    var json = Ext.decode(form.responseText);
    //console.log('json[0]= ', json[0]);


    myStore.setData(json);


    console.log('details store= ', myStore);


    myStore.each(function(record,id){


    console.log('record= ', record);






    });


    //console.log('getmodel =', myStore.getModel());


    myStore.getData().each(function(i) {
    console.dir(i.inspections().getData());


    i.inspections().getData().each(function(j) {
    console.dir(j.get('violationDescription'));
    });


    //console.dir(i.inspections().);
    });




    navigStores.push( {
    xtype: 'inspectionInfo',
    title: 'Details',
    html: 'test'


    });








    },
    failure: function(response, object) {
    console.log('response= ', response);
    console.log('object= ', object);
    Ext.Msg.alert('', 'No inspection results');
    }
    });
    },


    gcAddress: function(address) {




    var myMap = this.getMymap();
    var geocoder = new google.maps.Geocoder();


    myMap.setHeight(10);




    geocoder.geocode({'address': address},
    function(results,status) {
    if (status != google.maps.GeocoderStatus.OK) {
    Ext.Msg.alert("Address not found", status);
    } else {
    var pos = results[0].geometry.location;


    var marker = new google.maps.Marker(
    {
    position: new google.maps.LatLng(pos),
    map: myMap.getMap(),
    title: 'marker map'
    }
    );


    console.log("position", pos);
    }
    });


    },


    getCurrentLocation: function() {
    navigator.geolocation.getCurrentPosition(
    function(position) {
    var initialLocation = new google.maps.LatLng(position.coords.latitude,
    position.coords.longitude);


    console.log("initialLocation= ", initialLocation);


    myMap.setMapCenter({latitude: position.coords.latitude,
    longitude: position.coords.longitude}
    );


    return position;
    },
    function() {
    console.log('could not get current position');
    }
    );
    }


    });

  2. #2
    Sencha - Architect Dev Team jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    543
    Vote Rating
    19
    jjohnston will become famous soon enough jjohnston will become famous soon enough

      0  

    Default


    It's pretty hard to read this code without formatting, so apologies if I'm missing details. Can you explain in further detail what you are seeing? Does the onListDisclose handler fire? Do you get any errors in the browser's console? Is the component you have defined with the userAlias of 'inspectionInfo' being loaded?
    Jason Johnston
    @lojjic
    Sencha Architect Development Team

Thread Participants: 1