NC 刷新后,停留上一次选择的行(多行)

如图,我点击批量输入后,会调用列表刷新按钮。但数据之前选择的光标会跳到第一行,原先选择的行就不知道是哪行可。图为最终效果


// 批量输入日期后实时刷新 apply update(batch input date) to model(UI)
        getDataManager().refresh();
        // 拿到表头
        nc.ui.pub.beans.UITable htb = listView.getBillListPanel()
                .getHeadTable();
        htb.clearSelection();// 先清除

        // 设置列表选择模式
        htb.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        // re-find rows which still should be selected by judging pk*
        List<AggSellctrVO> newData = tmodel.getData();
        List<Integer> newnumList = new ArrayList(num.length);
        for (int i = 0, I = newData.size(); i < I; ++i) {
            if (pkList.remove(newData.get(i).getParentVO().getPk_sellctr_h())) {
                newnumList.add(i);
            }
        }
        int[] numr = integer2int(newnumList.toArray(new Integer[0]));// 存活(仍有对应纪录/最新)的被选行
        // 找到最小和最大 行号和列号
        int[] mm = minmax(numr, htb.getRowCount() - 1, -1);
        // 选中min~max
        htb.setRowSelectionInterval(mm[0], mm[1]);

        // start 使用排除法,清除不应选的行
        List<Integer> list = new ArrayList<Integer>(mm[1] - mm[0] + 1);
        for (int i = mm[0] + 1; i < mm[1]; ++i) {
            list.add(i);
        }
        for (int i = 0; i < numr.length; ++i) {
            Integer t = numr[i];
            list.remove(t);
            // 选中单元格
            htb.changeSelection(t, htb.getColumnCount(), false, true);
        }
        for (Integer i : list) {
            htb.getSelectionModel().removeSelectionInterval(i, i);
        }
        // end 使用排除法,清除不应选的行

作者:冬瓜茶饮料
出处:http://www.cnblogs.com/dongguacha/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

原文地址:https://www.cnblogs.com/dongguacha/p/7428212.html