简体   繁体   English

SmartGWT-根据另一个单元格中输入的值过滤Listgrid数据

[英]SmartGWT - Filter Listgrid data depending on entered value in another cell

I have a listgrid which has 4 columns. 我有一个有4列的listgrid。 Code,Name,Qty and Price. 代码,名称,数量和价格。 the name cell is a Combo Box which loads the names via datasource. 名称单元格是一个组合框,可通过数据源加载名称。 So far all is fine. 到目前为止,一切都很好。 now i want to be able to enter a code in the Code col cell and then i want the Combo box to display the name in the Name cell and the corresponding Price in the Price cell. 现在,我希望能够在Code col单元格中输入一个代码,然后让Combo框在Name单元格中显示名称,并在Price单元格中显示相应的Price。 Can somebody help me to achieve this.I have attached a screenshot to make things more clear. 有人可以帮我实现这一点吗?我附上了屏幕截图,使事情变得更加清晰。

cheers Zolf 欢呼佐尔夫

在此处输入图片说明

You can add ChangedHandler/BlurHandler on Code field which will be invoked when user has entered the Code and try to navigate to the next field. 您可以在Code字段上添加ChangedHandler / BlurHandler,当用户输入Code并尝试导航到下一个字段时将调用该字段。 Within the event handler, you need to wirte your logic to set Name and Price based on Code value. 在事件处理程序中,您需要弄清楚逻辑以根据Code值设置Name和Price。

    listGrid.getField("Code").addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {

            Record r=listGrid.getRecord(event.getRowNum());
            String code=(String)event.getValue();

            //add your logic to get Name and price based on Code value here
            r.setAttribute("Name",  name);
            r.setAttribute("Price", price);
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM