Java Code Examples for com.smartgwt.client.widgets.grid.ListGrid#setExpansionMode()

The following examples show how to use com.smartgwt.client.widgets.grid.ListGrid#setExpansionMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatalogBrowser.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private Canvas createAdvancedOptions() {
        formCatalog = createCatalogForm();

        lgResult = new ListGrid();
        lgResult.setDataSource(BibliographyQueryDataSource.getInstance());
//        lgResult.setUseAllDataSourceFields(true);
        ListGridField preview = new ListGridField(BibliographyQueryDataSource.FIELD_PREVIEW,
                i18n.CatalogBrowser_HeaderPreview_Title());
        ListGridField title = new ListGridField(BibliographyQueryDataSource.FIELD_TITLE,
                i18n.CatalogBrowser_HeaderTitle_Title());
        lgResult.setDetailField(BibliographyQueryDataSource.FIELD_PREVIEW);
        lgResult.setFields(title, preview);
//        lgResult.setAutoFetchData(true);
        lgResult.setHeight100();
        lgResult.setWidth100();
        lgResult.setCanExpandRecords(true);
        lgResult.setCanExpandMultipleRecords(false);
        lgResult.setExpansionMode(ExpansionMode.DETAIL_FIELD);
        lgResult.setSelectionType(SelectionStyle.SINGLE);
//        lgResult.setSelectionAppearance(SelectionAppearance.CHECKBOX);
        lgResult.setAlternateRecordStyles(true);
        lgResult.addDataArrivedHandler(new DataArrivedHandler() {

            @Override
            public void onDataArrived(DataArrivedEvent event) {
                if (event.getStartRow() == 0 && event.getEndRow() > 0) {
                    lgResult.focus();
                    lgResult.selectSingleRecord(0);
                }
            }
        });

        VLayout layout = new VLayout();
        layout.setMembers(formCatalog, lgResult);
        layout.setMargin(4);
        layout.setMembersMargin(4);
        layout.setOverflow(Overflow.AUTO);
        return layout;
    }
 
Example 2
Source File: WorkflowMaterialView.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private Widget createMaterialList() {
    materialGrid = new ListGrid() {

        @Override
        protected Canvas getExpansionComponent(final ListGridRecord record) {
            String type = record.getAttribute(WorkflowMaterialDataSource.FIELD_TYPE);
            DynamicForm form = null;
            if (MaterialType.FOLDER.name().equals(type)) {
                form = createFolderForm();
            } else if (MaterialType.PHYSICAL_DOCUMENT.name().equals(type)) {
                form = createPhysicalDocumentForm();
            } else if (MaterialType.DIGITAL_OBJECT.name().equals(type)) {
                form = createDigitalDocumentForm();
            }
            if (form != null) {
                return bindExpansinonForm(form, record);
            } else {
                return super.getExpansionComponent(record);
            }
        }

    };
    materialGrid.setSelectionType(SelectionStyle.SINGLE);
    materialGrid.setExpansionMode(ExpansionMode.DETAIL_FIELD);
    materialGrid.setCanExpandRecords(true);
    materialGrid.setCanExpandMultipleRecords(false);
    materialGrid.setAutoSaveEdits(false);
    materialGrid.setCanSort(false);
    materialGrid.setCanGroupBy(false);
    materialGrid.setWrapCells(true);

    CanvasSizePersistence persistence = new CanvasSizePersistence(parentName + ".WorkflowMaterialView.materialList", materialGrid);
    materialGrid.setHeight(persistence.getHeight());

    materialGrid.setDataSource(WorkflowMaterialDataSource.getInstance(),
            new ListGridField(WorkflowMaterialDataSource.FIELD_PROFILENAME),
            new ListGridField(WorkflowMaterialDataSource.FIELD_VALUE),
            new ListGridField(WorkflowMaterialDataSource.FIELD_WAY),
            new ListGridField(WorkflowMaterialDataSource.FIELD_NOTE),
            new ListGridField(WorkflowMaterialDataSource.FIELD_ID)
    );
    materialGrid.getField(WorkflowMaterialDataSource.FIELD_WAY).setHidden(jobMaterial);
    String dbPrefix = jobMaterial ? "WorkflowJobFormView.WorkflowMaterialView"
            : "WorkflowTaskFormView.WorkflowMaterialView";
    ListGridPersistance listGridPersistance = new ListGridPersistance(
            dbPrefix, materialGrid);
    materialGrid.setViewState(listGridPersistance.getViewState());
    return materialGrid;
}