Results 1 to 4 of 4

Thread: Data not loading into paging grid in GXT

  1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    61

    Default Data not loading into paging grid in GXT

    I am working with GWT, GXT and JSon reader to communicate with the server side code running on another port.

    GWT Host URL:
    http://localhost:8888/com.reliable.g...wtdemoapp.html
    Server Side Code URL:
    http://localhost:48080/springdemo/diagnosis/list.do

    When i test my code with the following URL (which comes with GXT examples) :
    http://extjs.com/forum/topics-remote.php
    it works fine and grid displays data.

    But when i am accessing the url: http://localhost:48080/springdemo/diagnosis/list.do from the GWT code, grid is not displaying data.

    When i check the firebug it shows the following json format as response:
    {"results":[{"id":"11111111333","dispatchType":"WL","level":1,"status":"PENDING","description":"test
    demo","active":1,"code":"1234"},{"id":"ff8081811ef9c1de011ef9c2473d0001","dispatchType":"WL","level"
    :1,"status":"PENDING","description":"Tetsing","active":1,"code":"3434"}],"total":2}

    My code
    =======
    @SuppressWarnings("unchecked")
    @Override
    protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    //Layout for container
    FlowLayout layout = new FlowLayout();
    setLayout(layout);
    //Grid Column Configs
    List<ColumnConfig> columnConfigList = new ArrayList<ColumnConfig>();

    ColumnConfig colConfig = null;

    colConfig = new ColumnConfig();
    colConfig.setId("id");
    colConfig.setHeader("ID");
    colConfig.setWidth(100);
    colConfig.setSortable(true);
    columnConfigList.add(colConfig);

    colConfig = new ColumnConfig();
    colConfig.setId("code");
    colConfig.setHeader("Code");
    colConfig.setWidth(100);
    colConfig.setSortable(true);
    columnConfigList.add(colConfig);

    colConfig = new ColumnConfig();
    colConfig.setId("description");
    colConfig.setHeader("Description");
    colConfig.setWidth(150);
    colConfig.setSortable(true);
    columnConfigList.add(colConfig);

    colConfig = new ColumnConfig();
    colConfig.setId("dispatchType");
    colConfig.setHeader("Dispatch Type");
    colConfig.setWidth(100);
    colConfig.setSortable(true);
    columnConfigList.add(colConfig);

    ColumnModel columnModel = new ColumnModel(columnConfigList);

    //Incoming data model type
    ModelType type = new ModelType();
    type.root = "results";
    type.totalName = "total";
    //type.recordName = "id";
    type.addField("id");
    type.addField("code");
    type.addField("description");
    type.addField("dispatchType");

    String url = "http://venu-laptop:48080/springdemo/diagnosis/list.do";
    ScriptTagProxy<Object, PagingLoadResult<ModelData>> proxy = new ScriptTagProxy<Object, PagingLoadResult<ModelData>>(url);

    //Reading JSon data
    JsonReader<PagingLoadConfig> reader = new JsonReader<PagingLoadConfig>(type) {
    @SuppressWarnings("unchecked")
    @Override
    protected ListLoadResult newLoadResult(PagingLoadConfig loadConfig, List<ModelData> models) {
    PagingLoadResult result = new BasePagingLoadResult(models, loadConfig.getOffset(), loadConfig.getLimit());
    return result;
    }
    };

    BasePagingLoader loader = new BasePagingLoader(proxy,reader);
    loader.addLoadListener(new LoadListener(){
    @Override
    public void loaderLoad(LoadEvent le) {
    MessageBox.alert("", "loaderLoad", null);
    }

    @Override
    public void loaderLoadException(LoadEvent le) {
    MessageBox.alert("", "loaderLoadException:"+le.exception.getLocalizedMessage(), null);
    }
    });
    loader.load(0, 50);

    final PagingToolBar toolBar = new PagingToolBar(5);
    toolBar.bind(loader);

    //Store
    ListStore<DiagnosisModel> listStore = new ListStore<DiagnosisModel>(loader);

    //Grid
    final Grid grid = new Grid(listStore, columnModel);
    grid.setVisible(true);
    grid.setTitle("Diagnosis");
    grid.setBorders(true);
    grid.setEnableColumnResize(true);
    grid.setWidth(600);
    grid.setHeight(200);
    grid.setToolTip("Diagnosis");
    grid.show();
    GWT.log("Records in grid::"+grid.getStore().getCount(), null);

    //Buttons-toolbar
    ToolBar buttonBar = new ToolBar();
    buttonBar.add(new AdapterToolItem(new Button("Add", new SelectionListener<ButtonEvent>() {
    @Override
    public void componentSelected(ButtonEvent ce) {
    //MessageBox.alert("add", "add", null);
    new DiagnosisAdd().show();
    }
    })));
    buttonBar.add(new AdapterToolItem(new Button("Edit")));
    buttonBar.add(new AdapterToolItem(new Button("Delete")));

    //add to content panel
    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setHeading("Diagnosis");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setWidth(700);
    cp.setHeight(200);
    cp.add(grid);
    cp.setBottomComponent(toolBar);
    cp.setTopComponent(buttonBar);

    add(cp);
    }

    Please let me know what is the problem with this code, it is very urgent.

    Also, let me know whether the ModelType in the code is correct or not.

    Thx.

  2. #2
    Ext User
    Join Date
    Oct 2008
    Location
    Atlanta ,GA
    Posts
    239

    Default

    ModelData should be like this. I think it should work this way
    Code:
            ModelType type = new ModelType();
            type.root = "gridData";
            type.addField("site", "site");
            type.addField("siteno", "siteno");    
            type.addField("dept", "dept");
            type.addField("deptno", "deptno");
            type.addField("SSN", "SSN");
            type.addField("lastname", "lastname");
            type.addField("firstname", "firstname");
            type.addField("fullname", "fullname");
            type.addField("competencyID", "competencyID");
            type.addField("competency", "competency");
            type.addField("relationalOperator", "relationalOperator");
            type.addField("value", "value");

  3. #3
    Ext User
    Join Date
    Jan 2009
    Posts
    61

    Default

    Solved.

  4. #4

    Default

    I have the same problem. How did you solve it?

Posting Permissions

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