I can't load my SmartGWT Datasource -
i'm modifying example of built-in-ds. way example works need select datasource, , table gets filled data there. idea show how same component can adapt multiple data sources. i've managed run example , works, i'm trying modify skip first step - there's 1 data source gets loaded "into" table. puzzles me should trivial reason it's not. i'll paste different parts of code, 1 works:
// create list of datasources listgrid grid = new listgrid(); grid.setleft(20); grid.settop(75); grid.setwidth(130); grid.setleavescrollbargap(false); grid.setshowsortarrow(sortarrow.none); grid.setcansort(false); grid.setfields(new listgridfield("dstitle", "select datasource")); // i'm loading 1 need grid.setdata(new listgridrecord[] { new dsrecord("predmeti", "predmeti")}); grid.setselectiontype(selectionstyle.single); grid.addrecordclickhandler(new recordclickhandler() { public void onrecordclick(recordclickevent event) { dsrecord record = (dsrecord) event.getrecord(); bindcomponents(record.getdsname()); } }); grid.draw();
and bindcomponents method:
private void bindcomponents(string dsname) { datasource ds = datasource.get(dsname); boundlist.setdatasource(ds); boundviewer.setdatasource(ds); boundform.setdatasource(ds); boundlist.fetchdata(); newbtn.enable(); savebtn.disable(); }
and works should. now, since have 1 data source, can skip grid , make call bindcomponents:
bindcomponents();
and bindcomponents looks this:
private void bindcomponents() { datasource ds = datasource.get("predmeti"); boundlist.setdatasource(ds); boundviewer.setdatasource(ds); boundform.setdatasource(ds); boundlist.fetchdata(); newbtn.enable(); savebtn.disable(); }
i can't see why second doesn't work, breaks on boundlist.setdatasource(ds);
. inspected in debug mode, object returned , looks "the same" in both cases reason doesn't work in second example, i'm guessing i'm instancing data source or, somehow, plain wrong :)
everything fine datasources, problem trivial , must have been tired - boundlist object @ time of call boundlist.setdatasource(ds);
not yet instantiated. kept getting null pointer exception, thought there wrong datasource.
Comments
Post a Comment