1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    23
    Vote Rating
    0
    yehezqiel is on a distinguished road

      0  

    Default [ask] how to change url of data store when a button was clicked

    [ask] how to change url of data store when a button was clicked


    please somebody help me..
    how to change url of data store when a button was clicked..

    my code for the grid is like this :
    Code:
    Ext.onReady
    (
        function()
        {
            Ext.QuickTips.init();
    
            var ds_model = Ext.data.Record.create
            ([
                'no',
                'message',
                'status'
            ]);
    
            var store = new Ext.data.Store
             ({
                url: 'doData?no=1',
                reader: new Ext.data.JsonReader
                (
                    {
                        root:'rows',
                        id: 'no'
                    },
                    [
                        'no',
                        'message',
                        'status'
                    ]
                )
            });
            store.load();
    
            var grid = new Ext.grid.EditorGridPanel
            ({
                renderTo: 'editor-grid',
                frame:true,
                title: '<div align="center">Message Detail</div>',
                height:500,
                width:900,
                autoWidth:true,
                store: store,
                clickstoEdit: 1,
                columns:
                [
                    {header: "No.", dataIndex: 'no', width:70},
                    {header: "Message", dataIndex: 'message', sortable:true, autoWidth:true, width: 700},
                    {header: "Status", dataIndex: 'status', sortable:true, autoWidth:true, width:100}
                ]
            });   
        }
    that's only show 1 row in the grid.
    and then i want if the user click the button, then the grid should show all records in the database..
    so i must change the url of data store, but i can't find how to do it..
    Code:
     function addRow()
            {
               grid.getStore().url = 'doData';   // it doesn't work
               grid.getStore().load();            //  the store was loaded with first url defined when create data store    
            }
    
            var btnAdd = new Ext.Button
        ({
                applyTo: 'btnAdd',
                text: 'Add Row'
        }) ;
        btnAdd.addListener('click',addRow);
    thx b4..

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    1. Why do you want to change the url. Most people that ask how to do this actually should do something different.
    2. You can change the url by using:
    Code:
    grid.getStore().proxy.setUrl('newurl', true);

  3. #3
    Sencha User
    Join Date
    May 2010
    Posts
    23
    Vote Rating
    0
    yehezqiel is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    1. Why do you want to change the url. Most people that ask how to do this actually should do something different.
    2. You can change the url by using:
    Code:
    grid.getStore().proxy.setUrl('newurl', true);
    thx.. but i've changed the code, not to change the url but change the params..

    and i want to ask, about how to change a value in a grid..
    for example, when a button was clicked then value of a specific record was changed..?

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    I don't understand the question...

  5. #5
    Sencha User
    Join Date
    May 2010
    Posts
    23
    Vote Rating
    0
    yehezqiel is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    I don't understand the question...
    ohh i see..

    hhmm for example there is a grid and a button..
    the grid have 3 columns : a, b ,c and several records..

    then if i click the button, value of column c in specific record should change into 'bla bla bla'..

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Code:
    handler: function(){
      var record = grid.getSelectionModel().getSelected();
      record.set('name-of-field-in-third-column', 'bla bla bla');
    }

  7. #7
    Sencha User
    Join Date
    May 2010
    Posts
    23
    Vote Rating
    0
    yehezqiel is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    Code:
    handler: function(){
      var record = grid.getSelectionModel().getSelected();
      record.set('name-of-field-in-third-column', 'bla bla bla');
    }
    thx for ur help..
    i'll try it..

Similar Threads

  1. Change Store Proxy URL without Creating New Store
    By rkdeiss in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 13 Apr 2010, 11:16 AM
  2. change url store on the fly
    By caponet in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 6 May 2009, 8:45 AM
  3. how can i change the url of store dynamically?
    By java_mid4 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 17 May 2008, 8:23 AM
  4. change the url of a data store
    By Foggy in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 30 Aug 2007, 1:04 AM

Thread Participants: 1