GRID Column Header replace caption

I’m trying to replace the grid’s column header by doing this

List<Transaction> payment = dbo.getTrannsactions(storeno,orderno);
grid.getColumn("Order_No").setCaption("Order No");
grid.setItems(payment);

but when it steps on the code it does nothing and with an error like below

SEVERE:
java.lang.NullPointerException

Can you help me on this?

You are doing things probably in wrong order and thus grid.getColumn(…) returns null and you get exception. Also normally property should not be named like “Order_No”.

can you give me a good example on this and how will i approach this issue?

You could check demo applications of selected Grid add-ons like

https://github.com/TatuLund/GridFastNavigation/tree/vaadin8

or

https://github.com/vaadin/grid-renderers-collection-addon/tree/vaadin8

(There are Vaadin 7 versions too if you need those)