Announcement

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

    display both checkbox/boolean in the same column of listgrid

    GWT v2.5
    SmartGWT 3.1d EE, (v8.3p_2012-12-28Enterprise Isomorphic-SmartClient-Package-Date: 2012-12-28)
    Browser: IE8
    Environment: Eclipse Indigo
    Java 1.6

    I have a customer that wants a checkbox column that when the cell is checked, it disables the row and replaces the checkbox with the date it was checked. Is this possible and how?

    I've figured out how to disable the row, but not put the date in. It seems impossible to me, but I don't want to tell my customer that is impossible unless I know for sure.

    #2
    You could use a normal text column instead, and add a cell formatter that renders either HTML for a checkbox or the date string

    Comment


      #3
      I assume, then, that I would need to intercept an event when saving that decodes that the checked cell into something meaningful for the datasource. Yes? (sounds tricky)

      Comment


        #4
        No - presumably, both values (checked-state and date) have fields in the DataSource, so just hide them in your grid and add a separate text field to the grid only (no DS entry), which formats as described previously (using the record-values of the fields hidden in the grid) - when the user clicks the checkbox, update the real boolean and/or date fields (the hidden ones)

        Comment


          #5
          Got it. Thanks

          Comment


            #6
            This is going pretty well except the part when I capture the check box being checked. RecordClickHandler doesn't get it. I want a way of flagging the checkbox/date field as checked/edited by the user so that at save time the invisible date can be set.

            Comment


              #7
              Please show your DataSource and grid code - and also indicate when the value of the manufactured field should change, ie, when the user clicks an empty checkbox, replace it with the date, or only after changes are saved?
              Last edited by Isomorphic; 1 Mar 2013, 06:55.

              Comment


                #8
                Code:
                <DataSource ID="quickquote_deal"
                	serverConstructor="com.pci.gp.server.QuickQuoteDealBeanDataSource">
                	<fields>
                		<field name="dealNum" type="sequence" primaryKey="true" hidden="false" />
                		<field name="orderNum" title="Order" type="long" />
                		<field name="study" title="Study" type="text" />
                		<field name="buySell" title="Buy Sell" type="integer" />
                		<field name="counterParty" title="Counterparty" type="text"/>
                		<field name="executionDate" title="Execution Date" type="date" />
                		<field name="transId" title="TRANZ ID (External Trade ID)" type="text" length="200" />
                		<field name="group" title="Group" type="integer" />
                		<field name="runId" title="RUN ID" type="integer" />
                		<field name="trader" title="Trader" type="text" />
                		<field name="deliveryPoint" title="Delivery Point" type="text" length="128" />
                		<field name="comment" title="Comment" type="text" length="400"/>
                		<field name="tradePrice" title="Trade Price $/MWh" type="float"/>
                		<field name="evaluateMethod" title="Evaluate Method" type="text" length="128" />
                		<field name="breakEven" title="Break Even $/MWh" type="float"/>
                		<field name="volume" title="Volume MWh" type="float"/>
                		<field name="he1" type="integer"/>
                		<field name="he2" type="integer"/>
                		<field name="he3" type="integer"/>
                		<field name="he4" type="integer"/>
                		<field name="he5" type="integer"/>
                		<field name="he6" type="integer"/>
                		<field name="he7" type="integer"/>
                		<field name="he8" type="integer"/>
                		<field name="he9" type="integer"/>
                		<field name="he10" type="integer"/>
                		<field name="he11" type="integer"/>
                		<field name="he12" type="integer"/>
                		<field name="he13" type="integer"/>
                		<field name="he14" type="integer"/>
                		<field name="he15" type="integer"/>
                		<field name="he16" type="integer"/>
                		<field name="he17" type="integer"/>
                		<field name="he18" type="integer"/>
                		<field name="he19" type="integer"/>
                		<field name="he20" type="integer"/>
                		<field name="he21" type="integer"/>
                		<field name="he22" type="integer"/>
                		<field name="he23" type="integer"/>
                		<field name="he24" type="integer"/>
                		<field name="he25" type="integer"/>
                		<field name="he26" type="integer"/>
                		<field name="he27" type="integer"/>
                		<field name="he28" type="integer"/>
                		<field name="he29" type="integer"/>
                		<field name="he30" type="integer"/>
                		<field name="he31" type="integer"/>
                		<field name="he32" type="integer"/>
                		<field name="he33" type="integer"/>
                		<field name="he34" type="integer"/>
                		<field name="he35" type="integer"/>
                		<field name="he36" type="integer"/>
                		<field name="he37" type="integer"/>
                		<field name="he38" type="integer"/>
                		<field name="he39" type="integer"/>
                		<field name="he40" type="integer"/>
                		<field name="he41" type="integer"/>
                		<field name="he42" type="integer"/>
                		<field name="he43" type="integer"/>
                		<field name="he44" type="integer"/>
                		<field name="he45" type="integer"/>
                		<field name="he46" type="integer"/>
                		<field name="he47" type="integer"/>
                		<field name="he48" type="integer"/>
                		<field name="he49" type="integer"/>
                		<field name="he50" type="integer"/>
                		<field name="he51" type="integer"/>
                		<field name="he52" type="integer"/>
                		<field name="he53" type="integer"/>
                		<field name="he54" type="integer"/>
                		<field name="he55" type="integer"/>
                		<field name="he56" type="integer"/>
                		<field name="he57" type="integer"/>
                		<field name="he58" type="integer"/>
                		<field name="he59" type="integer"/>
                		<field name="he60" type="integer"/>
                		<field name="he61" type="integer"/>
                		<field name="he62" type="integer"/>
                		<field name="he63" type="integer"/>
                		<field name="he64" type="integer"/>
                		<field name="he65" type="integer"/>
                		<field name="he66" type="integer"/>
                		<field name="he67" type="integer"/>
                		<field name="he68" type="integer"/>
                		<field name="he69" type="integer"/>
                		<field name="he70" type="integer"/>
                		<field name="he71" type="integer"/>
                		<field name="he72" type="integer"/>
                		<field name="header72" type="date"/>
                	</fields>
                
                /**
                	 * Builds the Quick Quote grid. Hides all Hour Ending fields by default.
                	 * Hour Ending (HE) fields are loaded into a list and configured in their own method for convenience...
                	 * because their are so many. Unlike the other fields, they are declared an instantiated as class
                	 * attributes so that they can be manipulated by other events.
                	 * 
                	 * 
                	 * @return
                	 */
                	public Canvas getGrid()
                	{
                
                		quickQuoteGrid.setShowAllRecords(true);
                		quickQuoteGrid.setAlternateRecordStyles(true);
                		quickQuoteGrid.setShowAllRecords(true);
                		quickQuoteGrid.setDataSource(customDS);
                		quickQuoteGrid.setCanEdit(true);
                		quickQuoteGrid.setLeaveScrollbarGap(false);
                		quickQuoteGrid.setDataFetchMode(FetchMode.LOCAL);
                		quickQuoteGrid.setAutoFetchData(false);
                		quickQuoteGrid.setAlternateRecordStyles(true);
                		quickQuoteGrid.setCanRemoveRecords(false);
                		quickQuoteGrid.setAutoSaveEdits(false);
                		quickQuoteGrid.setCanReorderRecords(true);
                		quickQuoteGrid.setCanResizeFields(true);
                		quickQuoteGrid.addDataArrivedHandler(new DataArrivedHandler()
                		{
                
                			@Override
                			public void onDataArrived(DataArrivedEvent event)
                			{
                				disableExecutedRecords();
                
                			}
                
                		});
                
                		ListGridField dealNumField = new ListGridField("dealNum");
                		dealNumField.setWidth(50);
                		dealNumField.setCanEdit(false);
                		dealNumField.setHeaderBaseStyle("noneditableHeader");
                
                		ListGridField orderNumField = new ListGridField("orderNum");
                		orderNumField.setWidth(50);
                		orderNumField.setHeaderBaseStyle("noneditableHeader");
                		orderNumField.setCanEdit(false);
                
                		SelectItem buySellSelect = new SelectItem();
                		buySellSelect.setValueMap("B", "S");
                		ListGridField buySellField = new ListGridField("buySell");
                		buySellField.setEditorType(buySellSelect);
                		buySellField.setWidth(50);
                		buySellField.setHeaderBaseStyle("editableHeader");
                
                		ListGridField counterPartyField = new ListGridField("counterParty");
                		counterPartyField.setWidth(75);
                		counterPartyField.setHeaderBaseStyle("editableHeader");
                
                		ListGridField executedField = new ListGridField();
                		executedField.setHeaderBaseStyle("editableHeader");
                		executedField.setWidth("175");
                		executedField.setTitle("Executed");
                		executedField.setCellFormatter(new CellFormatter()
                		{
                
                			@Override
                			public String format(Object value, ListGridRecord record, int rowNum, int colNum)
                			{
                				if (record.getAttributeAsDate("executionDate") == null)
                				{
                					return "<form name='execute' action='' method='get'> <input type='checkbox' name='execute' value='' /></form>";
                				}
                				return record.getAttributeAsDate("executionDate").toString();
                			}
                
                		});
                		executedField.addRecordClickHandler(new RecordClickHandler()
                		{
                			@Override
                			public void onRecordClick(RecordClickEvent event)
                			{
                				Record record = event.getRecord();
                				if (record.getAttribute("executionDate") == null)
                				{
                					executedList.add(event.getRecordNum());
                				}
                			}
                
                		});
                
                		ListGridField executionDate = new ListGridField("executionDate");
                
                		ListGridField transIdField = new ListGridField("transId");
                		transIdField.setWidth(150);
                		transIdField.setHeaderBaseStyle("editableHeader");
                
                		ListGridField groupField = new ListGridField("group");
                		groupField.setHeaderBaseStyle("editableHeader");
                		groupField.setWidth(75);
                
                		ListGridField runIdField = new ListGridField("runId");
                		runIdField.setHeaderBaseStyle("editableHeader");
                		runIdField.setWidth(75);
                
                		ListGridField traderField = new ListGridField("trader");
                		traderField.setHeaderBaseStyle("editableHeader");
                		traderField.setWidth(75);
                
                		ListGridField deliveryPointField = new ListGridField("deliveryPoint");
                		deliveryPointField.setWidth(75);
                		deliveryPointField.setHeaderBaseStyle("editableHeader");
                
                		ListGridField commentField = new ListGridField("comment");
                		commentField.setWidth(150);
                		commentField.setHeaderBaseStyle("editableHeader");
                
                		ListGridField tradePriceField = new ListGridField("tradePrice");
                		tradePriceField.setWidth(100);
                		tradePriceField.setHeaderBaseStyle("editableHeader");
                
                		SelectItem evaluateMethodSelect = new SelectItem();
                		evaluateMethodSelect.setValueMap("Pricing Matrix", "Redhawk CC1");
                		ListGridField evaluateMethodField = new ListGridField("evaluateMethod");
                		evaluateMethodField.setEditorType(evaluateMethodSelect);
                		evaluateMethodField.setWidth(100);
                		evaluateMethodField.setHeaderBaseStyle("editableHeader");
                
                		ListGridField breakEvenField = new ListGridField("breakEven");
                		breakEvenField.setWidth(110);
                		breakEvenField.setCanEdit(false);
                		breakEvenField.setBaseStyle("calcStyle");
                		breakEvenField.setHeaderBaseStyle("calcStyle");
                
                		ListGridField volumeField = new ListGridField("volume");
                		volumeField.setWidth(75);
                
                		quickQuoteGrid.setFields(
                				dealNumField,
                				buySellField,
                				counterPartyField,
                				executedField,
                				transIdField,
                				groupField,
                				runIdField,
                				traderField,
                				deliveryPointField,
                				commentField,
                				tradePriceField,
                				evaluateMethodField,
                				breakEvenField,
                				volumeField,
                				he1Field,
                				he2Field,
                				he3Field,
                				he4Field,
                				he5Field,
                				he6Field,
                				he7Field,
                				he8Field,
                				he9Field,
                				he10Field,
                				he11Field,
                				he12Field,
                				he13Field,
                				he14Field,
                				he15Field,
                				he16Field,
                				he17Field,
                				he18Field,
                				he19Field,
                				he20Field,
                				he21Field,
                				he22Field,
                				he23Field,
                				he24Field,
                				he25Field,
                				he26Field,
                				he27Field,
                				he28Field,
                				he29Field,
                				he30Field,
                				he31Field,
                				he32Field,
                				he33Field,
                				he34Field,
                				he35Field,
                				he36Field,
                				he37Field,
                				he38Field,
                				he39Field,
                				he40Field,
                				he41Field,
                				he42Field,
                				he43Field,
                				he44Field,
                				he45Field,
                				he46Field,
                				he47Field,
                				he48Field,
                				he49Field,
                				he50Field,
                				he51Field,
                				he52Field,
                				he53Field,
                				he54Field,
                				he55Field,
                				he56Field,
                				he57Field,
                				he58Field,
                				he59Field,
                				he60Field,
                				he61Field,
                				he62Field,
                				he63Field,
                				he64Field,
                				he65Field,
                				he66Field,
                				he67Field,
                				he68Field,
                				he69Field,
                				he70Field,
                				he71Field,
                				he72Field
                				);
                
                		quickQuoteGrid.hideField("executionDate");
                		// this must be done to build the list of hour ending fields for mass processing
                		this.loadHEFields();
                		// now we can configure the fields separately
                		configureHEFields();
                		// we want the hour ending fields to be hidden to start with
                		hideAllHEFields();
                
                		return quickQuoteGrid;
                	}
                
                </DataSource>

                Comment


                  #9
                  the field called "executedField" is the one I want to capture an event on

                  Comment


                    #10
                    You can react to the click by adding an onclick handler to your html checkbox

                    Comment


                      #11
                      How do I do this?

                      Originally posted by Isomorphic View Post
                      You can react to the click by adding an onclick handler to your html checkbox
                      How do I react to this? I'm not sure how the code looks in Java.

                      Comment

                      Working...
                      X