Results 1 to 2 of 2

Thread: How to remove special char sending query to ajax store

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    6
    Answers
    1

    Default How to remove special char sending query to ajax store

    Hi,

    I have a store, form, search field and grid working perfectly excpet that I don't know how to catch the refresh event to remove the potential special char ....

    Any help would be welcomed.

    D

    Code:
        Ext.define('LibPublilex', {
            extend: 'Ext.data.Model',
            fields: [
                {
                name: 'Abrev',
                mapping: 'Abrev'
                }, {
                name: 'Title',
                mapping: 'Title'
                }, {
                name: 'Art',
                type: 'int'
                }
            ],
            idProperty: 'book_id'
        });
    
        // create the Data Store
        var pstore = Ext.create('Ext.data.Store', {
            id: 'pstore',
            model: 'LibPublilex',
            // allow the grid to interact with the paging scroller by buffering
            buffered: true,
            
            // The topics-remote.php script appears to be hardcoded to use 50, and ignores this parameter, so we
            // are forced to use 50 here instead of a possibly more efficient value.
            pageSize: 50,
    
            // This web service seems slow, so keep lots of data in the pipeline ahead!
            leadingBufferZone: 1000,
            proxy: {
                // load using script tags for cross domain, if the data in on the same domain as
                // this page, an HttpProxy would be better
                type: 'ajax',
            async : false,
                url: 'php/ajax_get_books.php',
                reader: {
                    root: 'items',
                    totalProperty: 'TotalCount'
                },
                // sends single sort as multi parameter
                simpleSortMode: true,
                
                // Parameter name to send filtering information in
                filterParam: 'query',
    
                // The PHP script just use query=<whatever>
                encodeFilters: function(filters) {
                    return filters[0].value;
                }
            },
            listeners: {
                totalcountchange: onStoreSizeChangep
            },
            remoteFilter: true,
            autoLoad: true
        });
        
        function onStoreSizeChangep() {
            grid.down('#status').update({count: pstore.getTotalCount()});
        }
    
        function columnWrap(val){
        ss = grid.down('#psearch').getValue();
    
        tt = ss.split(' ');
    
        for (var i = 0; i < tt.length; i++) {
            if(i==0)
            {
                tval = val.replace(tt[i],'<span class="y">' + tt[i] + '</span>');
                cap = tt[i].substr(0,1).toUpperCase() + tt[i].substr(1).toLowerCase();
                tval = tval.replace(cap,'<span class="y">' + cap + '</span>');
                min = tt[i].substr(0,1).toLowerCase() + tt[i].substr(1).toLowerCase();
                tval = tval.replace(min,'<span class="y">' + min + '</span>');
            }
            else
            {
                tval = tval.replace(tt[i],'<span class="y">' + tt[i] + '</span>');
                cap = tt[i].substr(0,1).toUpperCase() + tt[i].substr(1).toLowerCase();
                tval = tval.replace(cap,'<span class="y">' + cap + '</span>');
                min = tt[i].substr(0,1).toLowerCase() + tt[i].substr(1).toLowerCase();
                tval = tval.replace(min,'<span class="y">' + min + '</span>');
            }
        }
    
            return '<div style="white-space:normal;">'+ tval +'</div>';
        }
    
    
    var grid = Ext.widget('form', {
            renderTo: 'col1',
        id:'tip_lib',
            frame: true,
            width: 420,
        height: 550,
        margin: '0 0 0 0',
            bodyPadding: 10,
            bodyBorder: false,
            title: 'Librairie Publilex',
            defaults: {
                anchor: '100%'
            },
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'none',
                invalidCls: '' //unset the invalidCls so individual fields do not get styled as invalid
            },
            items: [{
                 xtype: 'toolbar',
                items: [{
                    width: 280,
                    fieldLabel: 'Recherche',
            id : 'psearch',
                   labelWidth: 60,
                    xtype: 'searchfield',
                    store: pstore
                }, '->',{
                    xtype: 'component',
                    itemId: 'status',
                    tpl: 'R&eacute;sultat(s): {count}',
                    style: 'margin-right:5px'
                }]
            },{
        xtype: 'grid',
          store: pstore,
          height: 470,
            loadMask: true,
            selModel: {
                pruneRemoved: false
            },
            multiSelect: true,
        listeners: {
                selectionchange: function(selModel, selected) {
                        grid.down('#BAdd').setDisabled(false);
                    }
            },
            viewConfig: {
                trackOver: false
            },
            // grid columns
            columns:[{
     //           xtype: 'rownumberer',
            text : "Abrev",
            dataIndex: 'Abrev',
            renderer: columnWrap,
                width: 50,
                sortable: true
            },{
                tdCls: 'x-grid-cell-topic',
                text: "Lois et Ordonnances",
                dataIndex: 'Title',
                flex: 1,
            renderer: columnWrap,
                sortable: false
            },{
                text: "Art.",
                dataIndex: 'Art',
                align: 'center',
                width: 50,
                sortable: false
            }],
    
            dockedItems: [{
                xtype: 'container',
                dock: 'bottom',
                padding: '10 10 5 105',
    
                items: [{
                    xtype: 'button',
                    disabled: true,
            id: 'BAdd',
                    text: 'Ajouter &agrave; ma biblioth&egrave;que',
                    width: 160,
                    handler: function() {
                var form = this.up('form').getForm();
                        
                    }
                }] }]
    
    
          }]
        });

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    You could just use a convert function in the model field to remove special characters.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •