Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

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

  1. #21

    Default

    This is my js code.I want all the elements of the grid to be sent to my java class...
    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
    }
    }

    ],
    viewConfig : {
    forcefit : true
    },
    plugins : [editor],

    height : 700,
    width : 450,
    frame : true,
    tbar : [
    var data = [];
    grid_mapping.getStore().each(function(rec){
    data.push(rec.data);
    });
    Ext.Ajax.request({
    url: 'mappingScreen.action?act=testajax',
    jsonData: data,
    success: function(response){
    alert('success from ajax');
    }
    });
    }
    }]
    });

    I do get the o/p as expected in the POST tab of firebug but dont get anything in the response tab...
    How do i send all the elements to the server???
    plz help

  2. #22

    Default

    This is my js code...I want to select all the elements of grid and send them to the java class...
    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
    }
    }

    ],
    viewConfig : {
    forcefit : true
    },
    plugins : [editor],

    height : 700,
    width : 450,
    frame : true,
    tbar : [ {
    // cls: 'x-btn-text-icon',
    icon : 'images/save-icon.png',
    text : 'Save All Modifications',
    handler : function() {
    var data = [];
    grid_mapping.getStore().each(function(rec){
    data.push(rec.data);
    });
    Ext.Ajax.request({
    url: 'mappingScreen.action?act=testajax',
    method : 'get',
    jsonData: data,
    success: function(response){
    alert('success from ajax');
    }
    });
    }
    }]
    });
    I e1 get success from ajax in the alert box...and the expected o/p in post tab of firebug...bt the response tab is showing nothing...have i done something wrong??

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

    Default

    As I said:

    It all depends on what your server returns for the "mappingScreen.action?act=testajax" action.

  4. #24

    Default

    actually i want to send the data to mappingScreen.action?act=testajax action....
    what should i do?

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

    Default

    You can't use method:'GET' in combination with jsonData.

    What data format is the 'mappingScreen.action?act=testajax' expecting?

  6. #26

    Default

    {"list":[{"id":3354,"StdTaxElem":"a, Unsecured","UserElements":"aa"},{"id":3353,"StdTaxElem":"Foreign Currency Loans from Banks, Unsecured","UserElements":"Travelling Expenses"},{"id":3352,"StdTaxElem":"Foreign Currency Loans from Banks, Unsecured","UserElements":"Foreign Exchange Loss"},{"id":3351,"StdTaxElem":"Foreign Currency Loans from Banks, Unsecured","UserElements":"Preliminary Expenses Woff"},{"id":3350,"StdTaxElem":"Foreign Currency Loans from Banks, Unsecured","UserElements":"Printing & Stationery"},{"id":3349,"StdTaxElem":"Foreign Currency Loans from Banks, Unsecured","UserElements":"Registration Fees"},{"id":3347,"StdTaxElem":"Foreign Currency Loans from Banks, Unsecured","UserElements":"Underwritting Fees"},{"id":3346,"StdTaxElem":"Foreign Currency Loans from Banks, Unsecured","UserElements":"Profit & Loss Ac"}.......

    this is the expected format for mappingScreen.action?act=testajax

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

    Default

    So it should be:
    Code:
    Ext.Ajax.request({
      url: 'mappingScreen.action?act=testajax',
      method: 'POST',
      jsonData: {list: data},
      success: function(response){
        alert('success from ajax');
      }
    });
    or is your server expecting:
    Code:
    Ext.Ajax.request({
      url: 'mappingScreen.action?act=testajax',
      method: 'POST', // or GET
      params: {list: Ext.encode(data)},
      success: function(response){
        alert('success from ajax');
      }
    });

  8. #28

    Default

    Ext.Ajax.request({
    url: 'mappingScreen.action?act=testajax',
    method: 'POST',
    jsonData: {list: data},
    success: function(response){
    alert('success from ajax');
    }
    });
    works fine but i cant get the list on server...
    how can i now get all the elements which u specified in the list ?
    when i use request.getParameter("list") it shows null

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

    Default

    getParameter doesn't work with jsonData! Use my second example instead.

  10. #30

    Default

    actually my json string is very large that i cant use the get method...how can i get the parameter values of list then?
    thanks 4 ur replies

Page 3 of 4 FirstFirst 1234 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
  •