1. #1
    Sencha User
    Join Date
    Feb 2010
    Posts
    27
    Vote Rating
    0
    OBELIX is on a distinguished road

      0  

    Question Paging Grid problem

    Paging Grid problem


    Hi,

    I'v a problem with the Paging Grid.
    My Grid is correctly filled but the paging is always disabled.

    I don't know where is my mistake...

    Thanks

    JB

    Here the code :

    public void createExpander() {

    ModelType typeContrat = new ModelType();
    typeContrat.setRoot("lists");
    typeContrat.setTotalName("totalCount");
    typeContrat.addField("id", "id");
    typeContrat.addField("ref", "ref");

    // use a http proxy to get the data
    RequestBuilder builderContrats = new RequestBuilder(RequestBuilder.GET, theSearchUrl/* + "?" + theParam*/);
    HttpProxy<String> proxyContrats = new HttpProxy<String>(builderContrats);

    MyJsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader = new MyJsonPagingLoadResultReader<PagingLoadResult<ModelData>>(typeContrat);
    final BasePagingLoader<PagingLoadResult<ModelData>> loaderContrats = new BasePagingLoader<PagingLoadResult<ModelData>>(proxyContrats, reader);
    loaderContrats.setRemoteSort(true);



    // need a loader, proxy, and reader
    //JsonLoadResultReader<ListLoadResult<ModelData>> readerContrats = new JsonLoadResultReader<ListLoadResult<ModelData>>(typeContrat);
    //final BaseListLoader<ListLoadResult<ModelData>> loaderContrats = new BaseListLoader<ListLoadResult<ModelData>>(proxyContrats,readerContrats);

    final ListStore<ModelData> storeContrats = new ListStore<ModelData>(loaderContrats);

    final PagingToolBar toolBar = new PagingToolBar(50);
    toolBar.bind(loaderContrats);


    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    XTemplate tpl = XTemplate.create("<p><b>Test</p><br>");

    RowExpander expander = new RowExpander();
    expander.setTemplate(tpl);


    configs.add(expander);

    ColumnConfig column = new ColumnConfig();
    column.setId("id");
    column.setHeader("ID");
    column.setAlignment(HorizontalAlignment.LEFT);
    column.setWidth(75);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("ref");
    column.setHeader("Ref");
    column.setAlignment(HorizontalAlignment.LEFT);
    column.setWidth(75);
    configs.add(column);



    ColumnModel cm = new ColumnModel(configs);

    ContentPanel cp = new ContentPanel();
    cp.setHeading("Your Result");
    cp.setCollapsible(false);
    cp.setAnimCollapse(false);
    cp.setLayout(new FitLayout());
    cp.setSize(700, 300);



    final Grid<ModelData> grid = new Grid<ModelData>(storeContrats, cm);
    grid.setBorders(true);
    grid.setLoadMask(true);
    grid.getView().setEmptyText("No Result.");
    grid.setAutoExpandColumn("ID");
    grid.setHeight(300);
    grid.addPlugin(expander);
    grid.setStateful(true);
    grid.getView().setAutoFill(true);
    grid.getView().setForceFit(true);

    grid.enableEvents(true);
    cp.setBottomComponent(toolBar);


    grid.addListener(Events.Attach, new Listener<GridEvent<ModelData>>() {
    public void handleEvent(GridEvent<ModelData> be) {

    PagingLoadConfig config = new BasePagingLoadConfig();
    config.setOffset(0);
    config.setLimit(50);

    Map<String, Object> state = grid.getState();
    if (state.containsKey("offset")) {

    GWT.log("state.containsKey(offset)", null);

    int offset = (Integer)state.get("offset");
    int limit = (Integer)state.get("limit");
    config.setOffset(offset);
    config.setLimit(limit);
    }
    if (state.containsKey("sortField")) {
    config.setSortField((String)state.get("sortField"));
    config.setSortDir(SortDir.valueOf((String)state.get("sortDir")));
    }
    loaderContrats.load(config);
    }
    });


    loaderContrats.load(0,50);
    cp.removeAll();
    cp.add(grid);
    vp.layout();
    vp.add(cp);


    }



    and here the code of "MyJsonPagingLoadResultReader" class :

    public class MyJsonPagingLoadResultReader<D> extends JsonLoadResultReader<D> {

    public MyJsonPagingLoadResultReader(ModelType modelType) {
    super(modelType);
    }

    @Override
    protected BasePagingLoadResult<ModelData> newLoadResult(Object loadConfig, List<ModelData> models) {
    PagingLoadConfig config = (PagingLoadConfig) loadConfig;

    return new BasePagingLoadResult<ModelData>(models,
    config.getOffset(), -1);
    //, config.getOffset(), config.getLimit());

    }

    }

  2. #2
    Ext User
    Join Date
    Jan 2010
    Posts
    7
    Vote Rating
    0
    jonas.esser is on a distinguished road

      0  

    Default


    Hello,

    check/debug the return value of the Method basePagingLoadResult.getTotalLength(). The value must be > 50. Set the breakpoint at the method read in your JsonLoadResultReader.

    Best regards,
    Jonas

  3. #3
    Sencha User
    Join Date
    Feb 2010
    Posts
    27
    Vote Rating
    0
    OBELIX is on a distinguished road

      0  

    Question Paging Grid problem

    Paging Grid problem


    Hi,

    I do this.
    But now my Grid is filled with all the datas !
    The request return 47 items : thses 47 items are in my grid and the PagingToolBar say : "1 page of 1" (i ask 10 items per page).

    Tks for help.

    Here is my code :

    ModelType typeContrat = new ModelType();
    typeContrat.setRoot("lists");
    typeContrat.setTotalName("totalCount");
    typeContrat.addField("id", "id");
    typeContrat.addField("ref", "ref");


    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig();


    column = new ColumnConfig();
    column.setId("ref");
    column.setHeader("Ref");
    column.setAlignment(HorizontalAlignment.LEFT);
    column.setWidth(410);

    configs.add(column);

    // use a http proxy to get the data
    //MessageBox.alert("Model",theSearchUrl+"?" + theParam, null);
    RequestBuilder builderContrats = new RequestBuilder(RequestBuilder.GET, theSearchUrl);
    HttpProxy<String> proxyContrats = new HttpProxy<String>(builderContrats);

    // need a loader, proxy, and reader

    // Without Paging
    //JsonLoadResultReader<ListLoadResult<ModelData>> readerContrats = new JsonLoadResultReader<ListLoadResult<ModelData>>(typeContrat);
    //final BaseListLoader<ListLoadResult<ModelData>> loaderContrats = new BaseListLoader<ListLoadResult<ModelData>>(proxyContrats,readerContrats);

    // With Paging

    JsonLoadResultReader<PagingLoadResult<ModelData>> readerContrats =
    new JsonLoadResultReader<PagingLoadResult<ModelData>>(typeContrat) {
    protected ListLoadResult<ModelData> newLoadResult(Object loadConfig, List<ModelData> models) {
    //PagingLoadConfig pagingConfig = (PagingLoadConfig) loadConfig;
    //PagingLoadResult<ModelData> result = new BasePagingLoadResult<ModelData>(models, pagingConfig.getOffset(), pagingConfig.getLimit());

    PagingLoadResult<ModelData> result;

    if(loadConfig != null) {

    PagingLoadConfig pagingConfig = (PagingLoadConfig) loadConfig;
    result = new BasePagingLoadResult<ModelData>(models,
    pagingConfig.getOffset(), pagingConfig.getLimit());
    //MessageBox.alert("Model","Offset = " + String.valueOf(pagingConfig.getOffset()) + " - Limit = " + String.valueOf(pagingConfig.getLimit()), null);
    } else {
    //MessageBox.alert("Model","loadConfig is null", null);
    result = new BasePagingLoadResult<ModelData>(models, 0,models.size());
    }

    MessageBox.alert("Model",String.valueOf(result.getTotalLength()), null);

    return result;
    }

    };


    final PagingLoader<PagingLoadResult<ModelData>> loaderContrats = new BasePagingLoader<PagingLoadResult<ModelData>>(proxyContrats,readerContrats);


    loaderContrats.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() {
    public void handleEvent(LoadEvent be) {
    be.<ModelData> getConfig().set("start", be.<ModelData> getConfig().get("offset"));
    }
    });


    //loaderContrats.load(0,perPage);

    final ListStore<ModelData> storeContrats = new ListStore<ModelData>(loaderContrats);


    final PagingToolBar toolBar = new PagingToolBar(perPage);
    toolBar.bind(loaderContrats);


    ColumnModel cm = new ColumnModel(configs);
    ContentPanel cp = new ContentPanel();
    cp.setHeading("Your Result");
    cp.setCollapsible(false);
    cp.setAnimCollapse(false);
    cp.setLayout(new FitLayout());
    cp.setSize(700, 300);
    cp.setFrame(false);
    cp.setBottomComponent(toolBar);


    final Grid<ModelData> grid = new Grid<ModelData>(storeContrats, cm);

    grid.setAutoExpandColumn("ref");
    //grid.getView().setAutoFill(true);
    grid.getView().setEmptyText("Sorry - no matches. Please try some different terms.");
    grid.setBorders(true);
    grid.setLoadMask(true);
    grid.setStateful(true);

    grid.addListener(Events.Attach, new Listener<GridEvent<ModelData>>() {
    public void handleEvent(GridEvent<ModelData> be) {
    PagingLoadConfig config = new BasePagingLoadConfig();
    config.setOffset(0);
    config.setLimit(perPage);

    Map<String, Object> state = grid.getState();
    MessageBox.alert("Model","STATE = " + String.valueOf(state), null);

    if (state.containsKey("offset")) {
    int offset = (Integer)state.get("offset");
    int limit = (Integer)state.get("limit");
    config.setOffset(offset);
    config.setLimit(limit);
    }

    loaderContrats.load(config);
    }
    });

    cp.layout();

    cp.add(grid);
    vp.add(cp);


Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi