Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: select all elements of grid and send them in json string

  1. #1

    Default select all elements of grid and send them in json string

    Hi can i select all the elements displayed in grid and store it in a json string which i want to send to server ...
    my code is:

    var grid_mapping = new Ext.grid.GridPanel({
    id : 'grid_mapping',
    store : store_UEST,
    width : 450,
    height : 700,
    columns : [{
    header : "User Elements",
    width : 150,
    sortable : true,
    dataIndex : 'UserElements',
    mode : 'local',
    editor : {
    xtype : 'textfield',
    allowBlank : true
    }
    }, {
    header : "Standard Taxonomy Elements",
    width : 150,
    mode : 'local',
    sortable : true,
    dataIndex : 'StdTaxElem',
    editor : {
    xtype : 'textfield',
    allowBlank : false
    }
    }

    ],{)

    thanks in advance

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    1. Which one: All records, all selected record, all modified records?
    2. How should the data in this 'JSON string' be formatted?

  3. #3

    Default

    i want to select all records...
    for eg.
    if the grid's structure is:
    usrElem
    x a
    y b
    z c

  4. #4

    Default

    i want to select all records...
    for eg.
    if the grid's structure is:
    usrElem stdTaxElem
    x a
    y b
    z c

    then the json format i want to send on server ll be
    {[usrElem:x,stdTaxElem:a.....and so on

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Something like:
    Code:
    var data = [];
    grid.getStore().each(function(rec){
      data.push(rec.data);
    });
    Ext.Ajax.request({
      url: 'myurl',
      jsonData: data,
      success: function(response){
        ...
      }
    });

  6. #6

    Default

    hi condor thanks 4 ur reply

    can you plz elaborate...
    wht have you written inside success fn

  7. #7
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    This sends the grid data in JSON format to the server.

    The success handler is called with the response from your server (unless your server responds with an HTTP error status).

  8. #8

    Default

    but i am having 2 columns in my grid...will
    data.push(rec.data); work on both the col values? and response b send in json format like {[usrElem:x,stdTaxElem:a.....and so on

  9. #9
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    rec.data is an object containing all field values as an object keyed by field name.

  10. #10

    Default

    it worked...thanks a lot 4 ur posts
    i jus luv dis site

Page 1 of 4 123 ... LastLast

Similar Threads

  1. Best way to send String value in PageConfig object of a grid with remote paging
    By avilanchee in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 4 Mar 2010, 11:10 PM
  2. convert the data of the grid to JSON string
    By wguo in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 3 Jul 2009, 3:09 AM
  3. Load Remote Web Service JSON string in a GRID
    By alexbariv in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 11 Jun 2009, 3:21 AM
  4. grid.getStore().getModifiedRecords() -> JSON string -> Save to server
    By Setti in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 17 Jul 2008, 7:19 AM

Posting Permissions

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