【问题标题】:For a GWT java FlexTable how do I get the selected row number on value change对于 GWT java FlexTable,如何在值更改时获取选定的行号
【发布时间】:2016-02-24 09:09:38
【问题描述】:

我想存储包含更改日期的日期的 GWT FlexTable 行号。代码是:

//Add change handler for the task completion date.
dateCompletion.addValueChangeHandler(new ValueChangeHandler<java.util.Date>() {
    public void onValueChange(ValueChangeEvent<java.util.Date> event) {

        //TODO currentRow = flexAwardDescription.getRowIndex();
        //Display all YM who have not completed this task.
        AsyncCallback<List<YouthMember>> callback = new YMWithoutAwardHandler<List<YouthMember>>(CubBulkAward3View.this);
        rpc.getYMWithoutAwardList(ymAwardDetails.getad_Id(), callback);
    }
});

我找到了点击事件的答案;但是,不适用于更改事件。

【问题讨论】:

    标签: java gwt


    【解决方案1】:

    请在此处查看我的答案:Gwt getCellForEvent flexTable

    没有明显的方法可以做到,你可以做的是

    1. 获取事件源
    2. 将其转换为小部件
    3. 通过.getElement()获取它的元素,然后使用getParent()获取Cell,再使用getParent()获取行元素。

    然后你可以得到它的索引,在循环中将它与来自 rowFormatter 的行进行比较。

    【讨论】:

      【解决方案2】:

      我想出的解决方法是在单击事件上捕获行号(因为您必须先单击才能更改),然后在发生更改事件时使用此行号。

      //Get the row number of the row selected to display the names below it.
                      flexAwardDescription.addClickHandler(new ClickHandler() { 
                          public void onClick(ClickEvent event) {  
                               currentRow = flexAwardDescription.getCellForEvent(event).getRowIndex();
                          } 
                      }); 
      
                      //Add change handler for the task completion date.
                      dateCompletion.addValueChangeHandler(new ValueChangeHandler<java.util.Date>() {
                          public void onValueChange(ValueChangeEvent<java.util.Date> event) {
                              //Check if this is the completion row
                              if (ymAwardDetails.getad_Description().matches("(.*)Completed:(.*)")) {
                                  groupCompleted = "C";
                              }else{
                                  groupCompleted = "S";
                              }
                              awardDescriptionID = ymAwardDetails.getad_Id();
                              //Display all YM who have not completed this task.
                              AsyncCallback<List<YouthMember>> callback = new YMWithoutAwardHandler<List<YouthMember>>(CubBulkAward3View.this);
                              rpc.getYMWithoutAwardList(ymAwardDetails.getad_Id(), accountId, callback);
                          }
                      }); 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多