Announcement

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

    Creating column with different action buttons in ListGrid

    I having troubles creating column which will have different action buttons to perform editing, deleting, expanding, some other user action with record. Problem is I have already predefined DataSource in XML file connected to my DB like that:

    Code:
    <DataSource 
    	generatedBy="7.0rc2/SDK Development Only 2009-05-30"
    	serverType="sql"
    	dbName="MyDB"
    	dataSourceVersion="1"
    	tableName="PDA"
    	ID="PDA"
    >
    	<fields>
    		<field type="text" length="8" name="ID_CODE" required="true"></field>
    		<field primaryKey="true" type="text" length="16" name="PDA_ID" required="true"></field>
    		<field type="text" length="35" name="ROLE_NAME" foreignKey="PDA_ROLE.ROLE_NAME" required="true"></field>
    		<field type="number" name="STATUS" required="true" enumeration='true'></field>
    		<field type="number" name="REFRESH_BACKGROUND" required="true" enumeration='true'></field>
    	</fields>
    </DataSource>
    I cannot create fake column in Datasource XML because it doesn't exist in db table. I cannot add dynamically columns to ListGrid - because there is no way. I cannot add field to DataSource object because it cannot change anything when object already created.


    I even tried to do something like that (found in some sample):


    Code:
                    DataSource ds = DataSource.get("PDA");
    		final ListGrid listGrid = new ListGrid() {
    			@Override
    			protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
    
    				String fieldName = this.getFieldName(colNum);
    
    				if (fieldName.equals("REFRESH_BACKGROUND")) {
    					ImgButton chartImg = new ImgButton();
    					chartImg.setShowDown(false);
    					chartImg.setShowRollOver(false);
    					chartImg.setAlign(Alignment.CENTER);
    					chartImg.setSrc("silk/chart_bar.png");
    					chartImg.setPrompt("View Chart");
    					chartImg.setHeight(16);
    					chartImg.setWidth(16);
    					chartImg.addClickHandler(new ClickHandler() {
    						public void onClick(ClickEvent event) {
    							Window ww = new MapView(record.getAttribute("latitude"), record.getAttribute("logitude"),
    									record.getAttribute("pda_id"));
    							ww.show();
    						}
    					});
    
    					return chartImg;
    				}
    				return null;
    			}
    		};
    		listGrid.setHeight100();
    		listGrid.setWidth100();
    		listGrid.setAutoFetchData(true);
    		listGrid.setShowFilterEditor(true);
    		listGrid.setCanEdit(true);
    		listGrid.setCanRemoveRecords(true);
    		listGrid.setAlternateRecordStyles(true);
    		listGrid.setShowRecordComponents(true);
    		listGrid.setShowRecordComponentsByCell(true);
    		listGrid.setDataSource(ds);
    But function createRecordComponent(...) never executed.
    How to approach this?
    Last edited by ectar; 14 Apr 2010, 08:07.

    #2
    Just curious why createRecordComponent() does not invoked in my scenario.
    I suspect that has something to do with how I set the data, I do setDataSource(ds) and not setting data directly using setData() like in some othe showcase saple. I woul like to know how to intervene into process of setting data when using setDataSource();

    Should I do something with addDataArrivedHandler() and then massage columns? Or there is some method I can override in ListGrid?

    Actually I think createRecordComponent() dosnt work as it stated in documentation, it says: << When com.smartgwt.client.widgets.grid.ListGrid#getShowRecordComponents() is true, this method is called for a row/cell the first time it is brought into the drawArea, or when there are not yet any components in the pool. The colNum parameter is applicable only when listGrid.getShowRecordComponentsByCell returns true. >>

    why wont it be invoked when I setDataSource() and listGrid automatically fetches data?

    Comment


      #3
      Any suggestions?

      Can somebody suggest me at least what I might try to achieve my goal?

      Comment


        #4
        The Bug

        Showcase sample http://www.smartclient.com/smartgwt/showcase/#grid_cell_widgets doesn't work if recompiled under smartGWT 2.1 and GWT 2.0.2, Java5.

        Grid displayed but no buttons shown, execution never reaches protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {}

        Comment


          #5
          Any comments?

          Comment


            #6
            Bug reported, it is a bit frustrating that I spent quite a time thinking I'm just stupid and don't know what I'm doing, but it is actually broken. Thank you people for the "real" help.

            http://code.google.com/p/smartgwt/issues/detail?id=450
            Last edited by ectar; 22 Apr 2010, 10:48.

            Comment


              #7
              Please do not file issues unless you've received confirmation that you've got a bug.

              Your report doesn't make a lot of sense. You seem to be claiming the Showcase sample doesn't work in the same environment in which it's actually running online. So most likely you've got a botched installation of some kind.

              Comment


                #8
                I've tried one more time.

                Clean Eclipse downloaded, GWT installed, GWT Project created, Added smartGWT2.1 jar and smartGWTee.jar, copied source files, same story.
                But this time it was GET 2.0.3 and Java6.

                Comment


                  #9
                  I manage this sample get working but

                  In my gwt.xml I have this entry:

                  Code:
                    <inherits name='com.google.gwt.user.User'/>
                    <inherits name="com.smartgwtee.SmartGwtEE"/>
                  when I replaced it to this

                  Code:
                    <inherits name='com.google.gwt.user.User'/>
                    <inherits name="com.smartgwt.SmartGwt"/>
                  it start working, BUT I need it working with SmartGwtEE!

                  And when I do

                  Code:
                  <inherits name="com.smartgwt.SmartGwt"/>
                  <inherits name="com.smartgwtee.SmartGwtEENoScript"/>
                  It doesn't work anymore.
                  So looks like SmartGWTEE functionality interfere somehow with SmartGWT !!!

                  Please advise
                  Last edited by ectar; 22 Apr 2010, 12:54.

                  Comment


                    #10
                    Sounds as though you are just winging the install.

                    Actual installation instructions are here.

                    Comment


                      #11
                      You had filed an issue and I verified that the testcase works fine. This was also confirmed by you in tracker.

                      Sanjiv

                      Comment

                      Working...
                      X