Search code examples
smartgwtsmartgwt-pro

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


I have a listgrid which has 4 columns. 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. Can somebody help me to achieve this.I have attached a screenshot to make things more clear.

cheers Zolf

enter image description here


Solution

  • 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. Within the event handler, you need to wirte your logic to set Name and Price based on Code value.

        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);
            }
        });