0
votes

We have been working in this application for quite some time developed using Sencha Touch 2.

We usually test and debug the code using Chrome and Ripple.

The problem we are facing is that we added some custom search and grouping logic to one of our lists views. When tested and debugged using chrome everything worked as expected, but then we used the command to package it in order to integrate it with Cordova and generate the Android and iOS applications. We used the following command:

sencha app build native

For some reason, the code generated with this command is overwriting our custom search and grouping JavaScript code.

Why could this be happening. We like to thing that it is not the sencha tool not working correctly but rather something we are doing wrong that is causing this to happen.

We are clueless on what could the reason be. Can anyone throw some light into this? Why are our custom grouper and filtering functions being overwritten when packaging the application?

Bellow is an extract on how we define the grouping method in our store. Again, when we try this in our debug environment it works correctly. The problem is that when we package it using the above command, the grouper function gets replaced by the default sencha touch 2 grouping function that returns the first character of the string.

Ext.define('app.store.definitions',{
    extend:'Ext.data.Store',
    requires: [
        'Ext.data.Connection'
    ],

    config:{
        fields: ['id','name', 'Description'],
        sorters: 'name',
        grouper: function(record) {
           // these are the translation arrays
           var accents = "ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛ";
           var desiredvalue = "AAAAAEEEEIIIIOOOOUUUU";

           // first we upercase the first character of the name
           var firstchar = record.get('name').toUpperCase()[0];

           //next we check if it is a special character by checking position in accents string
           var n = accents.indexOf(firstchar);

          // if character is in accents (means it is a special character) we get corresponding normal character
          if (n <> -1)
             { firstchar = desiredvalue.charAt(n);
             };

          // and now we just return this value ad the grouping value 
          return firstchar;
      }

After executing the "sencha app build native" and decompresing the generated code we realize that the grouper function has been replaced by

       grouper: function(record) {
          var firstchar = record.get('name`);
          return firstchar;
      }
1
Did you modify the Touch source files directly or extend the list component?Jeff Wooden
We extend the list, but most of the code that gets overwritten is in the store definition or in the controller. As an example I have added the code of our grouping function in the original question.osantos
I don't understand what could be the reason why when building the native app, our code gets replaced for these functions.osantos

1 Answers

0
votes

I tested a native build on one of my apps with a grouper and it doesn't replace my code. I think you need to specify the groupFn paramater inside of the grouper object literal. See the following example:

Ext.define('app.store.definitions',{
    extend:'Ext.data.Store',
    requires: [
        'Ext.data.Connection'
    ],

    config:{
        fields: ['id','name', 'Description'],
        sorters: 'name',
        grouper: {
            groupFn: function(record) {
                // these are the translation arrays
                var accents = "ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛ";
                var desiredvalue = "AAAAAEEEEIIIIOOOOUUUU";

                // first we upercase the first character of the name
                var firstchar = record.get('name').toUpperCase()[0];

                //next we check if it is a special character by checking position in accents string
                var n = accents.indexOf(firstchar);

                // if character is in accents (means it is a special character) we get corresponding normal character
                if (n <> -1) { 
                    firstchar = desiredvalue.charAt(n);
                };

                // and now we just return this value ad the grouping value 
                return firstchar;
           }
       }