Announcement

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

    How to transferSelectedData without save data on ListGrid

    //========== LEFT GRID ================
    ListGridField subjectIdField = new ListGridField(SubjectTable.SUBJECT_ID, "pk");
    subjectIdField.setHidden(true);

    ListGridField subjectCodeField = new ListGridField(SubjectTable.SUBJECT_CODE, "Subject Code");
    subjectCodeField.setAlign(Alignment.CENTER);

    ListGridField subjectNameField = new ListGridField(SubjectTable.SUBJECT_NAME, "Subject Name");
    subjectNameField.setAlign(Alignment.CENTER);

    ListGridField lessonTypeField = new ListGridField(SubjectTable.FIX_LESSON_TYPE,"Lesson Type");
    lessonTypeField.setAlign(Alignment.CENTER);

    ListGridField subjectWeightField = new ListGridField(SubjectTable.SUBJECT_WEIGHT,"Weight");
    subjectWeightField.setAlign(Alignment.CENTER);

    ListGrid subjectGrid = new ListGrid();
    subjectGrid.setWidth100();
    subjectGrid.setHeight(224);
    subjectGrid.setAutoFetchData(true);
    subjectGrid.setShowAllRecords(true);
    subjectGrid.setCanDragRecordsOut(true);
    subjectGrid.setDragDataAction(DragDataAction.COPY);
    subjectGrid.setDataSource(SubjectDS.getInstant());
    subjectGrid.setFields(subjectIdField,
    subjectCodeField,
    subjectNameField,
    lessonTypeField,
    subjectWeightField);
    //========= RIGHT GRID =======================
    ListGridField courseSubjectIdField = new ListGridField(CourseSubjectTable.COURSE_SUBJECT_ID, "pkCourseSubject");
    courseSubjectIdField.setHidden(true);

    ListGrid subjectChoosed = new ListGrid();
    subjectChoosed.setWidth100();
    subjectChoosed.setHeight(224);
    subjectChoosed.setCanAcceptDroppedRecords(true);
    subjectChoosed.setAutoSaveEdits(false);
    subjectChoosed.setAutoFetchData(false);
    subjectChoosed.setPreventDuplicates(true);
    subjectChoosed.setShowAllRecords(true);
    subjectChoosed.setDataSource(CourseSubjectDS.getInstant());
    subjectChoosed.setFields(courseSubjectIdField ,
    subjectIdField,
    subjectCodeField,
    subjectNameField,
    lessonTypeField,
    subjectWeightField);

    TransferImgButton transferButton = new TransferImgButton(TransferImgButton.RIGHT);
    transferButton.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
    subjectChoosed.transferSelectedData(subjectGrid);
    }
    });

    HLayout subjectWidget = new HLayout();
    subjectWidget.addMember(subjectGrid);
    subjectWidget.addMember(transferRighButton );
    subjectWidget.addMember(subjectChoosed);

    //======SUBJECT DATASOURCE ============
    DataSourceIntegerField subjectIdField = new DataSourceIntegerField(SubjectTable.SUBJECT_ID);
    subjectIdField.setHidden(true);
    subjectIdField.setPrimaryKey(true);

    DataSourceTextField subjectCodeField = new DataSourceTextField(SubjectTable.SUBJECT_CODE);
    subjectCodeField.setRequired(true);

    DataSourceEnumField fixLearningTypeField = new DataSourceEnumField(SubjectTable.FIX_LESSON_TYPE);
    fixLearningTypeField.setRequired(true);
    fixLearningTypeField.setValueMap(FixComboboxConstant.getLessonTypeConstant());

    DataSourceTextField subjectNameField = new DataSourceTextField(SubjectTable.SUBJECT_NAME);
    subjectNameField.setRequired(true);

    DataSourceTextField subjectAbbreviationField = new DataSourceTextField(SubjectTable.SUBJECT_ABBREVIATION);
    subjectAbbreviationField.setRequired(true);

    DataSourceFloatField subjectWeightField = new DataSourceFloatField(SubjectTable.SUBJECT_WEIGHT);
    subjectWeightField.setRequired(true);

    DataSourceFloatField subjectHoursField = new DataSourceFloatField(SubjectTable.SUBJECT_HOURS);
    subjectHoursField.setRequired(true);

    setFields(subjectIdField,
    subjectCodeField,
    fixLearningTypeField,
    subjectNameField,
    subjectAbbreviationField,
    subjectWeightField,
    subjectHoursField);

    setClientOnly(true);

    //====== COURSE_SUBJECT DATASOURCE =======
    DataSourceIntegerField courseSubjectIdField = new DataSourceIntegerField(CourseSubjectTable.COURSE_SUBJECT_ID);
    courseSubjectIdField.setHidden(true);
    courseSubjectIdField.setPrimaryKey(true);

    DataSourceIntegerField subjectIdField = new DataSourceIntegerField(SubjectTable.SUBJECT_ID);
    subjectIdField.setForeignKey(SubjectDS.subjectId+"."+SubjectTable.SUBJECT_ID);
    subjectIdField.setRequired(true);

    DataSourceTextField subjectCodeField = new DataSourceTextField(SubjectTable.SUBJECT_CODE);
    subjectCodeField.setRequired(true);

    DataSourceEnumField fixLessoningTypeField = new DataSourceEnumField(SubjectTable.FIX_LESSON_TYPE);
    fixLessoningTypeField.setRequired(true);
    fixLessoningTypeField.setValueMap(FixComboboxConstant.getLessonTypeConstant());

    DataSourceTextField subjectNameField = new DataSourceTextField(SubjectTable.SUBJECT_NAME);
    subjectNameField.setRequired(true);

    DataSourceFloatField subjectWeightField = new DataSourceFloatField(SubjectTable.SUBJECT_WEIGHT);
    subjectWeightField.setRequired(true);

    setFields(courseSubjectIdField,
    subjectIdField,
    subjectCodeField,
    fixLessoningTypeField,
    subjectNameField,
    subjectWeightField);

    *******************
    My problem is when listgrid always auto save when transfered to right grid i cannot get the data which no pk to call Hibernate.SaveOrUpdate(Object)
    So i want to save myself when press a save button and got pk from hibernate to retrieve to the record after.

    Can anyone help me how to do that thing?

    Thank you

    Sharif

    Sorry for bad english.

    #2
    Same problem here:

    destination.setAutoSaveEdits(false)
    destination.transferSelectedData(source);

    The call to transferSelectedData() triggers an update, but I like to do a mass update later.

    What are we missing?


    SmartClient Version: v9.0p_2013-10-01/PowerEdition Deployment (built 2013-10-01)

    Comment


      #3
      Maybe the solution is hidden in this showcase:
      http://www.smartclient.com/smartgwtee/showcase/#hbRelationOneToMany

      i.e.
      destination.setSaveLocally(true);

      Comment


        #4
        Solution found:
        http://forums.smartclient.com/showthread.php?t=24237

        Comment

        Working...
        X