1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default Answered: How to use extraParams?

    Answered: How to use extraParams?


    Hi,

    First I am sending a request (param) to the server and using the same PHP for another grid, but that grid doesn't give me data with passed param , but when I send param in the url I can get it done. When I searched for it, there is an object extraParams, I am using like,

    Code:
    {
        xtype: 'gridpanel',
        url: 'php/update.php',
        extraParams: {
            'columnname': selectedField
        }
    }
    This doesn't seem to work, it isn't sending the extra parameter. What am I doing wrong?

    Thanks.

  2. Where are you wanting to build the array of selected field values? You shouldn't do this on every checkbox select, but rather just prior to performing your AJAX call (I'm assuming on a button push somewhere?).

    Code:
    var selections = Ext.getCmp('your_grid_id').getSelectionModel().getSelection();
    var arr = [];
    Ext.each(selections, function(rec, index) {
        arr.push(rec.get('Field'));
    });
    You can then pass "arr" as your extra param during the AJAX call.

  3. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default


    I have to send parameter somewhere else, I did that and it worked. Now I have a CheckboxModel, I need to get value(s) of selected fields.

    I have code like,
    Code:
    onCheckboxselectionmodelSelect: function(rowmodel, record, index, options) {
            checkedField = record.get('Field');
    }
    checkedField has the currently selected value, how can I get array of selected values (comma separated, may be join() will do)?

    Can someone help me? Thanks in advance.

  4. #3
    Sencha User
    Join Date
    Oct 2009
    Posts
    95
    Answers
    3
    Vote Rating
    2
    Albareto is on a distinguished road

      0  

    Default


    grid.getSelectionModel().getSelection()

    That should return all the selected rows.

  5. #4
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default


    Hi Albareto,

    I have seen that as a solution in many threads, I am having my grid in Ext.apply(), how do i address 'grid' in grid.getSelectionModel().getSelection(), because it says 'undefined' . Please give me a simple code to get values and tell me how that is saved, like an array or we can have it comma separated (better for my requirement).

    And also, I am getting JSON response from PHP, how do I save one of the values to a variable? Please help.

    Thanks!

  6. #5
    Sencha User
    Join Date
    Oct 2009
    Posts
    95
    Answers
    3
    Vote Rating
    2
    Albareto is on a distinguished road

      0  

    Default


    I cannot help you if you don't show your code. You can get components by using the Ext.ComponentQuery object or, in case your grid has an id, using Ext.getCmp('yourId');

    For saving values that you receive after an update you can capture the load event from your store and put the logic you need there. But again without a sample code of how you are doing things it is difficult to answer your questions.

  7. #6
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default


    Hi,

    The grid looks like,

    Code:
    Ext.applyIf(me, {
                items: [
                    {
                        xtype: 'gridpanel',
                        height: 223,
                        width: 133,
                        store: 'Store',
                        columns: [
                            {
                                xtype: 'gridcolumn',
                                width: 105,
                                dataIndex: 'Field',
                                text: 'Fields'
                            }
                        ],
                        viewConfig: {
                            autoRender: true
                        },
                        selModel: Ext.create('Ext.selection.CheckboxModel', {
                            listeners: {
                                select: {
                                    fn: me.onCheckboxselectionmodelSelect,
                                    scope: me
                                }
                            }
                        })
                    }
                ]
            });
    
            me.callParent(arguments);
        },
    
    onCheckboxselectionmodelSelect: function(rowmodel, record, index, options) {
    checkedField = record.get('Field');
    }
    So the checked values in this grid will be needed for another operation, for example, if the grid has,
    test1
    test2
    test3
    with checkboxes for it on left and if I am checking test1 and test2, I should have it like
    Code:
    variable = {test1, test2}
    or something like this comma separated.

    For JSON, if I am getting response like,
    Code:
    {"value":[{"Field":"test1","table":"tablename"},{"Field":"test2","table":"tablename"},{"Field":"test3","table":"tablename"}]
    I want to save table to a variable, how that can be done?

    Thanks in advance!

  8. #7
    Sencha User
    Join Date
    Jan 2011
    Posts
    546
    Answers
    1
    Vote Rating
    53
    willigogs is a jewel in the rough willigogs is a jewel in the rough willigogs is a jewel in the rough

      1  

    Default


    Where are you wanting to build the array of selected field values? You shouldn't do this on every checkbox select, but rather just prior to performing your AJAX call (I'm assuming on a button push somewhere?).

    Code:
    var selections = Ext.getCmp('your_grid_id').getSelectionModel().getSelection();
    var arr = [];
    Ext.each(selections, function(rec, index) {
        arr.push(rec.get('Field'));
    });
    You can then pass "arr" as your extra param during the AJAX call.

  9. #8
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default


    Hi willigogs,

    Thanks for the reply. I did the one you told on a button and it works good, I check on checkboxes and while clicking button it sends like,

    HTML Code:
    http://localhost/testing/php/update.php?fieldName=test1&fieldName=test2
    Can I have these values like,
    Code:
    fieldName=test1, test2
    I need to use this for another operation.

    Please help in saving the JSON response to a variable I asked in my previous post.

    Thanks!

Thread Participants: 2