Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7638873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:16:45+00:00 2026-05-31T08:16:45+00:00

I have a datasource in SmartGWT. How do i extract data from it? I

  • 0

I have a datasource in SmartGWT. How do i extract data from it? I have tried using fetchData()method but then in criteria i need to add a value i.e.

Criteria cr = new Criteria();
cr.addCriteria("Name", "Name_Value");

In order to execute a selectall on the DataSource what do i need to do?

Here is the code :

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DragDataAction;
import com.smartgwt.client.widgets.TransferImgButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VStack;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.tree.TreeGridField;

public class TreeDragNodesSample implements EntryPoint {
TreeGrid grid1 = new TreeGrid();
TreeGrid grid2 = new TreeGrid();
String name=null;
    public void onModuleLoad() {
Tree test = new Tree();

        grid1.setDragDataAction(DragDataAction.COPY);
        grid1.setAutoFetchData(true);
        grid1.setDataSource(EmployeeXmlDS.getInstance());
        grid1.setWidth(200);
        grid1.setHeight(200);
        grid1.setShowEdges(true);
        grid1.setBorder("0px");
        grid1.setBodyStyleName("normal");
        grid1.setShowHeader(false);
        grid1.setLeaveScrollbarGap(false);
        grid1.setEmptyMessage("<br>Drag & drop parts here");
        grid1.setManyItemsImage("cubes_all.png");
        grid1.setAppImgDir("icons/16/");
        grid1.setNodeIcon("cube.png");
        grid1.setFolderIcon("person.png");
        grid1.setCanReorderRecords(true);
        grid1.setCanAcceptDroppedRecords(true);
        grid1.setCanDragRecordsOut(true);
        grid1.setCanAcceptDrop(true);
        grid1.setCanDrop(true);
        TreeGridField tname = new TreeGridField("Name");
        TreeGridField child = new TreeGridField("ChildID");
        TreeGridField reps = new TreeGridField("ReportsTo");
        grid1.setFields(tname);

        grid2.setLeft(250);
        grid2.setAutoFetchData(true);
        grid2.setDataSource(EmployeeXmlDSDrop.getInstance());
        grid2.setWidth(200);
        grid2.setHeight(200);
        grid2.setShowEdges(true);
        grid2.setBorder("0px");
        grid2.setBodyStyleName("normal");
        grid2.setShowHeader(false);
        grid2.setLeaveScrollbarGap(false);
        grid2.setEmptyMessage("<br>Drag & drop parts here");
        grid2.setManyItemsImage("cubes_all.png");
        grid2.setAppImgDir("icons/16/");
        grid2.setNodeIcon("cube.png");
        grid2.setFolderIcon("person.png");
        grid2.setCanReorderRecords(true);
        grid2.setCanAcceptDroppedRecords(true);
        grid2.setCanDragRecordsOut(true);
        grid2.setCanAcceptDrop(true);
        grid2.setCanDrop(true);
        TreeGridField tname2 = new TreeGridField("Name");
        TreeGridField child2 = new TreeGridField("ChildID");
        TreeGridField reps2 = new TreeGridField("ReportsTo");
        grid2.setFields(tname2);

        VStack moveControls = new VStack(10);
        moveControls.setWidth(32);
        moveControls.setHeight(74);
        moveControls.setLayoutAlign(Alignment.CENTER);

        TransferImgButton rightArrow = new TransferImgButton(TransferImgButton.RIGHT, new ClickHandler() {

            public void onClick(ClickEvent event) {
                grid2.transferSelectedData(grid1);
            }
        });
        moveControls.addMember(rightArrow);

        TransferImgButton leftArrow = new TransferImgButton(TransferImgButton.LEFT, new ClickHandler() {

            public void onClick(ClickEvent event) {
                grid1.transferSelectedData(grid2);
            }
        });
        moveControls.addMember(leftArrow);

        HStack grids = new HStack(10);
        grids.setHeight(160);
        grids.addMember(grid1);
        grids.addMember(moveControls);
        grids.addMember(grid2);
        grids.draw();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:16:46+00:00Added an answer on May 31, 2026 at 8:16 am

    You do not execute a select all operation on a DataSource. You rather do it on its databounded object, e.g. the associated ListGrid. Provided that the data have been set and loaded in the ListGrid listGrid, you just call

    listGrid.getRecords();
    

    which returns a Record[], with all the visible, or matching to a set of criteria records.
    Another option, for databounded ListGrids, is to use the ResultSet object. This is handy
    when you want to find specific records in your data, but since you require all the records, I would suggest you just use the getAllRecords method. For more details look at the API

    Update: Based on your code extract, I can now see that you are using a TreeGrid, instead of a ListGrid. Thus the method you should use is the:

    TreeGrid.getTree().getAllNodes();
    

    This will give you all the nodes of the tree, that have been loaded, no matter if they are opened or closed. The ListGrid.getRecords() would only return the opened nodes. Notice that the TreeGrid, by default, loads its data on demand. So if you want to retrieve all the tree’s nodes, you have to deactivate this feature and pre-load all the data. This can of course create speed issues. To achieve this do the following:

    TreeGrid.setLoadDataOnDemand(Boolean.FALSE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datasource that gets data from the server. It is then used
I currently have a datasource from a client in the form of XML, this
On JBoss 5.1.0 I have Datasource (PostgreSQL 8.3.11) configured using *-ds.xml (standard jboss DS).
I have: ComboBox.DataSource = System.Enum.GetValues(typeof(ImageLayout)); but how do I set the ComboBox.SelectedItem to an
I have followed the instructions at http://www.javacodegeeks.com/2011/01/advanced-smartgwt-tutorial-part-1.html and tried to create a simple screen
Suppose we have a DataSource bind to a collection from Database. There is no
I have a repeater that displays some data from a SQL query: <asp:Repeater runat=server
I have a problem with datasource binding in ListGrid with smartGWT. I have GWT-RPC-DataSource
I have a datasource, how to check if its ok? maybe somehow using jmx-console?
I have a datasource (BindingList) with many Users, but there are some users I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.