Announcement

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

    Copy the inputted value from one ListGridField to another ListGridField

    Hello everyone!
    I need help!

    I have a code like this.

    ListGridField agentGrid = new ListGridField("agent", "Agents");

    ListGridField percentCommissionGridAgent = new ListGridField(
    "percentCommissionAgent", "Percent of Commission");

    ListGridField commissionValueGridAgent = new ListGridField(
    "commissionValueAgent", "Commission Value");

    I put those three ListGridFields in a ListGrid.


    *Here's what i want to do.*

    I will input a value from the 'Percent of Commission' ListGridField and

    then after i input it (by pressing enter or clicking somewhere) I want to put

    that value in the '"Commission Value" ListGridField.

    Please see the attached image.

    Please help. Thanks!
    Attached Files
    Last edited by tropi_333; 19 Mar 2015, 03:24.

    #2
    Hi tropi_333,

    does it work to set the name to the same field?
    Code:
    ListGridField percentCommissionGridAgent = new ListGridField(
    "percentCommissionAgent", "Percent of Commission");
    
    ListGridField commissionValueGridAgent = new ListGridField(
    "percentCommissionAgent", "Commission Value");
    If not, then:
    Code:
    ListGridField commissionValueGridAgent = new ListGridField(
    "commissionValueAgent", "Commission Value");
    commissionValueGridAgent.setCellFormatter(...)
    using the ListGridRecord in CellFormatter to access your other column.

    Or, most fancy (did not try it) like in this sample?

    Best regards,
    Blama

    Comment


      #3
      Hi Blama. Thank you for your response.

      If not, then:
      Code:
      ListGridField commissionValueGridAgent = new ListGridField(
      "commissionValueAgent", "Commission Value");
      commissionValueGridAgent.setCellFormatter(...)
      using the ListGridRecord in CellFormatter to access your other column.

      I already try that one.
      I have a code like this.

      Code:
      commissionValueGridAgent.setCellFormatter(new CellFormatter() {
      					
      @Override
      public String format(Object value, ListGridRecord record, int rowNum,
      							int colNum) {
      						
      long commissionValue = record.getAttributeAsLong("percentCommissionAgent");
      
      return ""+commissionValue;
      		}
      });
      and this one.
      Code:
      agentListGrid.addEditorExitHandler(new EditorExitHandler() {
      					
      @Override
      public void onEditorExit(EditorExitEvent event) {
      											if(event.getColNum() == 1){
      ListGridRecord record = (ListGridRecord)event.getRecord(); 
       int gdpFieldNum = agentListGrid.getFieldNum("commissionValueAgent");  
      							agentListGrid.refreshCell(event.getRowNum(), gdpFieldNum, true, true); 
      							SC.warn(record.getAttribute("percentCommissionAgent")+"::"+commissionValueGridAgent.getValueField());	
      		}
      					
      	}  
      					
      });
      It works pretty good. But my problem now is that when i print the value of the percentCommissionGridAgent and commissionValueGridAgent ListGridFields(by using the SC.warn) it says that their values are null.
      And then when i click on that cell again, their values appear.
      Please see the attached images. Thank you!
      Attached Files

      Comment

      Working...
      X