Hi Fabien,

Which version of ULC are you using?

>>
        is it possible to make a sort only when the user click on the
header and when some data are change in the grid then the sort doesn't
made again? 
>>

See the snippet below. The table is not sorted automatically when you
change data either on the client or on the server. Table gets sorted only
when you click on the header. This is the default behavior.

Can you please send me a snippet where the table is getting sorted on
modifying the data?

Thanks and regards,

Janak

-----------------------------------------
Janak Mulani

email: [email protected]
url: http://www.canoo.com <http://www.canoo.com/> 

Beyond AJAX - Java Rich Internet Applications

http://www.canoo.com/ulc
----------------------------------------- 
________________________________

        From: [email protected]
[mailto:[email protected]] On Behalf Of Fabien RIVOISY
        Sent: Wednesday, February 03, 2010 2:33 PM
        To: [email protected]
        Subject: [ULC-developer] ULCTable with editable column and sort
model

        Hello, 
        
        i want to make an ulctable with 2 editable columns and the model
can be sort. 
        But when i make change in a cell after the fire cell change then
the model is sort again even if i modify cell . 
        is it possible to make a sort only when the user click on the
header and when some data are change in the grid then the sort doesn't
made again? 
        Or sortmodel must only use for read only grid? 
        
        Thanks 
        
        Fabien
-------------------------------------------


import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ClientContext;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.event.ITableModelListener;
import com.ulcjava.base.application.event.TableModelEvent;
import com.ulcjava.base.application.table.DefaultTableModel;
import com.ulcjava.base.application.table.ULCTableColumn;
import com.ulcjava.base.development.DevelopmentRunner;
import com.ulcjava.base.shared.UlcEventConstants;

public class TableCellEditAndSort extends AbstractApplication {


    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(TableCellEditAndSort.class);
        DevelopmentRunner.run();
    }

    public void start() {
        final DefaultTableModel model = new DefaultTableModel(new
Object[][] { { "A1", "B1", "C1" },
                { "A2", "B2", "C2" } }, new String[] { "Col0", "Col1",
"Col2" });
        final ULCTable table = new ULCTable(model);
        table.setAutoCreateRowSorter(true);

        ClientContext.setModelUpdateMode(model,
UlcEventConstants.SYNCHRONOUS_MODE);
        model.addTableModelListener(new ITableModelListener() {

            public void tableChanged(TableModelEvent event) {
                System.out.println(".tableChanged()");
                // table.getRowSorter().sort();
            }
        });


        ULCTableColumn column = table.getColumnModel().getColumn(0);

        ULCBoxPane content = new ULCBoxPane(true);
        ULCScrollPane scp = new ULCScrollPane(table);
        content.add(ULCBoxPane.BOX_EXPAND_EXPAND, scp);

        ULCButton button = new ULCButton("Change Cell");
        button.addActionListener(new IActionListener() {
            public void actionPerformed(ActionEvent event) {
                String s = (String)table.getValueAt(0, 1);
                table.setValueAt( "Z" + s, 0, 1);
            }
        });
        
        content.add(button);
        
        ULCFrame frame = new ULCFrame("TableRowSorterSnippet");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.add(content);
        frame.setSize(300, 300);
        frame.setVisible(true);
    }
}
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to