Announcement

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

    Issue with multi select drop down

    Hi Isomorphic;
    My SmartGWT version is: 'v11.0p_2017-02-11/PowerEdition Deployment (built 2017-02-11)'.
    My application is using SmartGWT + Spring + Hibernate.
    I am facing issue with multi select dropdown in the grid.
    My grid is fetching data from a database view. (material_attr_v) , base table for view is material_attr.

    Entity for view:

    @Entity
    @Table(name = "material_attr_v")
    public class MaterialAttrViewEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "material_attr_id")
    private Integer materialAttrId;

    @Column(name = "PREP_CODE")
    private String materialPrepDesc;
    }

    Entity for table:

    @Entity
    @Table(name = "material_attr")
    public class MaterialAttr {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "material_attr_id")
    @Access(AccessType.PROPERTY)
    private int materialAttrId;


    @OneToMany(mappedBy ="materialAttr" , fetch = FetchType.EAGER,cascade = CascadeType.ALL)
    private List<MaterialPrep> materialPrep;

    }

    Code for Select Item editor in the grid:

    protected static FormItem getEditorForAdditionalFields(ListGridEditorContext context,
    ListGrid materialAttributeGrid2) {
    SelectItem prepClassSelectItem= new SelectItem();
    final DataSource codeDS = DataSource.get("Code");
    prepClassSelectItem.setWidth(300);
    ListGridField codeField = new ListGridField("code");
    codeField.setWidth(100);
    codeField.setTitle("Prep Class");
    ListGridField codeDescField = new ListGridField("Description");
    codeDescField.setTitle("Description");
    codeDescField.setShowHover(true);
    codeDescField.setWidth(200);
    prepClassSelectItem.setDisplayField("code");
    prepClassSelectItem.setValueField("codeId");
    prepClassSelectItem.setPickListFields(codeField, codeDescField);
    prepClassSelectItem.setOptionDataSource(codeDS);
    Criteria criteria = new Criteria();
    criteria.addCriteria("name", "attrUOM");
    prepClassSelectItem.setOptionCriteria(criteria);
    prepClassSelectItem.setMultiple(true);
    return prepClassSelectItem;
    }

    MaterialAttrView.ds.xml:

    <DataSource ID="MaterialAttrView"
    schemaBean="com.assaabloy.pricebook.server.persistence.model.MaterialAttrViewEntity">
    <field name="materialAttrId" hidden="true" primaryKey="true" />
    <field name="materialPrepDesc" includeFrom="code.code" hidden="true"/>
    <field name="materialPrepDesc" type="text" title="Material Prep" displayField="materialPrepDesc" width="150"/>
    </DataSource>

    Code.ds.xml:

    <DataSource ID="Code" schemaBean="com.assaabloy.pricebook.server.persistence.model.Code" >
    <field name="codeId" hidden="true" primaryKey="true" />
    <field name="code" type="text" title="Code" width="150"/>
    <field name="description" type="text" title="Code" width="150"/>
    </DataSource>

    Now I am facing below 2 issues with this select item:
    1. It displays value field in place of display field while editing.
    Once the value are saved into DB, it shows the display field correctly.

    2. It don't show the selected items checked in drop down.

    Please suggest.


    Last edited by preeti_kanyal; 14 Mar 2017, 18:10.

    #2
    Like most of the posts from your team, this post is again incomplete in a way that makes it impossible to tell you what is wrong. Please once against revisit the FAQ and also the Debugging overview, ideally with your whole team. Posting partial information is a waste of your time as well as ours.

    The first thing to do is to look at the data you are actually returning from your server, using the RPC tab of the Developer Console. Most likely you are just not sending the displayField information. Also possible is that your server is responding incorrectly to fetches caused by the formItem.fetchMissingValues behavior (read the docs for details).

    Comment


      #3
      I have already gone through the FAQs.
      Issue is not with the data because data returned looks correct.
      I would try to explain my issue again because i am facing select item issue in multiple scenarios.

      I have a table 'A' which looks like below:
      Id Name BField
      1 10,11
      2 11,12

      Table 'B':
      Id Name
      10
      11
      12

      Here column BField in table 'A' contains comma sepated Ids of table 'A'.
      For Table 'A' ,column BField is just a text column and there is no foreign key constraint between 'A' and 'B'.

      Now in my grid i want to show grid column mapping to 'BField' as a multiselectItem.

      But i face below issue:

      It displays value field (Ids) in place of display field(Name) while editing.
      Once the value are saved into DB, it shows the display field correctly.

      [FONT=Arial, Verdana, sans-serif][COLOR=#000000]2. It don't show the selected items checked in drop down.[/COLOR][/FONT]

      [FONT=Arial, Verdana, sans-serif][COLOR=#000000]I feel here the issue is because there is no relationship defined at table level between there 2 tables.[/COLOR][/FONT]
      [FONT=Arial, Verdana, sans-serif][COLOR=#000000]If you could understand my issue than please suggest.[/COLOR][/FONT]

      Comment


        #4
        While you may have gone through the FAQ, it appears you don't know what's in it. You've omitted basics that are required when posting issues (such as the RPC responses) and you are still posting very partial code that cannot be run.

        Please revisit the FAQ and Debugging overviews so you understand what details you need to post, so that it will be possible for others to help you.

        Comment


          #5
          Hi team, We had posted this query long back. Now that w ehave the support subscription, request you to please look into it and provide the solution for the same.

          Comment


            #6
            We already responded above, even when you did not have support. Please revisit our response - you need to post several more pieces of information before it will be possible for anyone to help you.

            Comment

            Working...
            X