1. #1
    Sencha User
    Join Date
    Apr 2012
    Location
    Marseille, France
    Posts
    6
    Vote Rating
    0
    bobby_mars is on a distinguished road

      0  

    Default Answered: ExtJS 4.1 Ext.data.Record.create "no method substring"

    Answered: ExtJS 4.1 Ext.data.Record.create "no method substring"


    Hello,

    I want to create a chart. With my previous version of ExtJS it worked, but with ExtJS 4.1 not.
    I get my data array from a servlet and then I create a Record:
    Code:
    var recordLinks = new Array(9);
    recordLinks[0] = {name: 'datetime'};
    recordLinks[1] = {name: 'sensorName'};
    recordLinks[2] = {name: 'period0'};
    recordLinks[3] = {name: 'destoreDate'};
    recordLinks[4] = {name: 'destoreReason'};
    recordLinks[5] = {name: 'destoreYVal'};
    recordLinks[6] = {name: 'alarmDate'};
    recordLinks[7] = {name: 'alarmName'};
    recordLinks[8] = {name: 'alarmYVal'};
    
    var fields = new Array(9);
    fields[0] = 'datetime';
    fields[1] = 'sensorName';
    fields[2] =  'period0';
    fields[3] = 'destoreDate';
    fields[4] =  'destoreReason';
    fields[5] = 'destoreYVal';
    fields[6] = 'alarmDate';
    fields[7] = 'alarmName';
    fields[8] = 'alarmYVal';
    
    var rec = new Ext.data.Record.create(recordLinks);
    
    var reader = new Ext.data.ArrayReader({}, rec);
    var store = new Ext.data.Store({
    			fields: fields,
    			reader: reader,
    			data  : data
    		});
    Here is en example of an element of my data array:
    Code:
    {"datetime": '24/11/2012 10:45:42', "sensorName":'TEST 1',"period0": 22.80,"destoreDate":'24/11/2012 10:47:38',"destoreReason":'Checking',"destoreYVal":30.0,"alarmDate":undefined,"alarmName":undefined,"alarmYVal":undefined}
    My problem happens when initializing my variable "rec". I get this exception:
    TypeError: Object [object Object] has no method 'substring'
    Thanks to debug breakpoints, I determined that it happens in the ext-all-debug script , function parseNamespace line 4493 :
    if (name === from || name.substring(0, from.length) === from) {

    I tried to set my variable with simple String and it failed too (ex: recordLinks[0] = 'datetime';)

    Does anyone know why it does not work?

    Thanks!

  2. There are many things wrong with the code. Could be simplified down to:

    Code:
    var store = new Ext.data.Store({
        fields: ['name'],
        data  : [
            {name: 'datetime'},
            {name: 'sensorName'},
            {name: 'period0'},
            {name: 'destoreDate'},
            {name: 'destoreReason'},
            {name: 'destoreYVal'},
            {name: 'alarmDate'},
            {name: 'alarmName'},
            {name: 'alarmYVal'}
        ]
    });

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,642
    Vote Rating
    899
    Answers
    3574
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Are you trying to create a record with this:

    Code:
    var rec = new Ext.data.Record.create(recordLinks);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Location
    Marseille, France
    Posts
    6
    Vote Rating
    0
    bobby_mars is on a distinguished road

      0  

    Default


    Yes I do.
    And it works for my previous script...

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,642
    Vote Rating
    899
    Answers
    3574
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    There are many things wrong with the code. Could be simplified down to:

    Code:
    var store = new Ext.data.Store({
        fields: ['name'],
        data  : [
            {name: 'datetime'},
            {name: 'sensorName'},
            {name: 'period0'},
            {name: 'destoreDate'},
            {name: 'destoreReason'},
            {name: 'destoreYVal'},
            {name: 'alarmDate'},
            {name: 'alarmName'},
            {name: 'alarmYVal'}
        ]
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Apr 2012
    Location
    Marseille, France
    Posts
    6
    Vote Rating
    0
    bobby_mars is on a distinguished road

      0  

    Default


    Ok, it works !
    Thanks a lot!

    I hope I'll be more efficient for the next migration to new ExtJS versions

Thread Participants: 1