Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    12.0p Problem with SelectItem pickListCriteria that are not applied in BatchUploader ListGrid

    Hi Isomorphic,

    I have a problem with SelectItems in BatchUploader in SmartGWT. As I assumed that it will happen in SmartClient as well, I prepared a testcase in the current showcase sample, which does not show the error.
    My problem is that the pickListCriteria are not applied in SmartGWT. Do you see a reason why this could be? My gut feeling says it might be related to pickListProperties, but I'm not sure and did not test it, yet, in SmartGWT.

    In order to have the code, here my sample so far:
    Code:
    isc.BatchUploader.create({
        ID:"uploader",
        height: 400,
        width: "100%",
        uploadDataSource: supplyItemCustom,
        uploadFormFields: [
            { name: "stringValue", title: "String Value", type: "text", wrapTitle: false },
            { name: "numericValue", title: "Numeric Value", type: "number", wrapTitle: false }
        ],
        uploadFormProperties: {
            titleWidth: 110 // make room for long titles defined above without overflowing
        },
        gridProperties: {
            height: 200
        },
        gridFields: [
            {name:"itemID"},
            {name:"itemName"},
            {name:"units",
             //editorType:"SelectItem",
             editorProperties: {
                title:"My Unit",
                optionDataSource: "supplyItemUnits",
                pickListProperties: { dataFetchMode: "basic" },
                valueField: "id",
                displayField: "description",
                sortField: "description",
                pickListCriteria: { fieldName: "description", operator: "iContains", value: "l" },
                pickListHeaderHeight: 0,
                pickListFields: [ {name: "id"}, {name: "description"} ]
               }
            },
            {name:"unitCost"}
        ]
    
    });
    
    isc.DynamicForm.create({
        ID: "partialCommitsForm",
        items: [
            {
                name:"partialCommits", 
                wrapTitle: false,
                title:"Partial Commit Mode", 
                type:"select", 
                defaultValue: "prompt",
                valueMap:{
                    allow: "Allow", 
                    prevent: "Prevent", 
                    prompt: "Prompt",
                    retain: "Retain"
                },
                changed : function(form, item, value) {
                    uploader.partialCommit = value;
                }
            }
        ]
    });
    
    isc.VStack.create({
        width:"100%",
        layoutMargin:10,
        membersMargin: 10,
        members:[
            partialCommitsForm,
            uploader
        ]
    });
    Best regards
    Blama

    #2
    Hi Isomorphic,

    sorry, coding mistake here I really can't explain.
    For the same of completeness, if someone ever needs this testcase, here a similar one in SmartGWT BuiltInDS-based:

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.FetchMode;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.BatchUploader;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle("editorProperties not used in BatchUploader (working in testcase)");
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            BatchUploader batchUploader = new BatchUploader();
            batchUploader.setWidth100();
            batchUploader.setUploadDataSource(DataSource.get("employeesUpload"));
    
            ListGridField nameLGF = new ListGridField("Name");
    
            ListGridField managerLGF = new ListGridField("ReportsTo");
            MySelectItem editor = new MySelectItem();
            editor.setPickListCriteria(new AdvancedCriteria(new Criterion("EmployeeType", OperatorId.EQUALS, "part time")));
            managerLGF.setEditorProperties(editor);
    
            ListGridField genderLGF = new ListGridField("Gender");
    
            batchUploader.setGridFields(nameLGF, genderLGF, managerLGF);
    
            w.addItem(batchUploader);
            w.show();
        }
    
        private class MySelectItem extends SelectItem {
            public MySelectItem() {
                super("ReportsTo");
                setTitle("Some title");
                setOptionDataSource(DataSource.get("employees"));
    
                ListGrid plProps = new ListGrid();
                plProps.setDataFetchMode(FetchMode.BASIC);
                setPickListProperties(plProps);
    
                setValueField("EmployeeId");
                setDisplayField("Name");
                setSortField("Name");
                setPickListCriteria(new AdvancedCriteria(new Criterion("EmployeeType", OperatorId.EQUALS, "full time")));
    
                ListGridField plFieldName = new ListGridField("Name");
                ListGridField plFieldEmployeeType = new ListGridField("EmployeeType");
                ListGridField plFieldGender = new ListGridField("Gender");
                ListGridField plFieldEmployeeId = new ListGridField("EmployeeId");
    
                setPickListHeaderHeight(0);
                setPickListFields(plFieldName, plFieldEmployeeType, plFieldGender, plFieldEmployeeId);
            }
        }
    }
    BuiltInDS.html change:
    Code:
    <script src="builtinds/sc/DataSourceLoader?dataSource=employees,employeesUpload,batchUpload"></script>
    batchUpload.ds.xml:
    Code:
    <!-- DataSource to support the BatchUploader component
         NOTE: This is not the DataSource responsible for performing the batch update of verified
               records, it is an internal resource used to handle the initial upload of the client-
               side file. The only time you would ever want to change this DataSource is if you wanted 
               a hook into the upload process (for security reasons, for example).  See the 
               BatchUploader documentation in the SmartClient reference.
    -->
    
    <DataSource ID="batchUpload">
        <operationBindings>
            <operationBinding operationType="add" operationId="upload" serverMethod="batchUpload">
                <explanation>First do: boolean conversions, date conversions and list conversions. Then validate and upload data.</explanation>
            </operationBinding>
            <operationBinding operationType="custom" operationId="wipeData" serverMethod="wipeData">
                <explanation>This method is generated by smartGWT.</explanation>
            </operationBinding>
            <operationBinding operationType="loadSchema">
                <explanation>This method is generated by smartGWT.</explanation>
            </operationBinding>
        </operationBindings>
        <serverObject ID="batchUpload" className="com.lmscompany.lms.server.worker.BatchUploadDMI" dropExtraFields="false">
            <visibleMethods>
                <method name="batchUpload" />
                <method name="wipeData" />
            </visibleMethods>
        </serverObject>
    </DataSource>
    Sorry again for the confusion.

    Best regards
    Blama

    Comment

    Working...
    X