You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clientsidewidgets-grid.asciidoc 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ---
  2. title: Grid
  3. order: 4
  4. layout: page
  5. ---
  6. [[clientsidewidgets.grid]]
  7. = Grid
  8. The [classname]#Grid# widget is the client-side counterpart for the server-side
  9. [classname]#Grid# component described in
  10. <<../components/components-grid#components.grid,"Grid">>.
  11. The client-side API is almost identical to the server-side API, so its
  12. documentation is currently omitted here and we refer you to the API
  13. documentation. In the following, we go through some customization features of
  14. [classname]#Grid#.
  15. [[clientsidewidgets.grid.renderers]]
  16. == Renderers
  17. As described in
  18. <<../components/components-grid#components.grid.renderer,"Column
  19. Renderers">>, renderers draw the visual representation of data values on the
  20. client-side. They implement [interfacename]#Renderer# interface and its
  21. [methodname]#render()# method. The method gets a reference to the element of the
  22. grid cell, as well as the data value to be rendered. An implementation needs to
  23. modify the element as needed.
  24. For example, [classname]#TextRenderer# is implemented simply as follows:
  25. [source, java]
  26. ----
  27. public class TextRenderer implements Renderer<String> {
  28. @Override
  29. public void render(RendererCellReference cell,
  30. String text) {
  31. cell.getElement().setInnerText(text);
  32. }
  33. }
  34. ----
  35. The server-side renderer API should extend [classname]#AbstractRenderer# or
  36. [classname]#ClickableRenderer# with the data type accepted by the renderer. The
  37. data type also must be given for the superclass constructor.
  38. [source, java]
  39. ----
  40. public class TextRenderer extends AbstractRenderer<String> {
  41. public TextRenderer() {
  42. super(String.class);
  43. }
  44. }
  45. ----
  46. The client-side and server-side renderer need to be connected with a connector
  47. extending from [classname]#AbstractRendererConnector#.
  48. [source, java]
  49. ----
  50. @Connect(com.vaadin.ui.renderer.TextRenderer.class)
  51. public class TextRendererConnector
  52. extends AbstractRendererConnector<String> {
  53. @Override
  54. public TextRenderer getRenderer() {
  55. return (TextRenderer) super.getRenderer();
  56. }
  57. }
  58. ----
  59. Renderers can have parameters, for which normal client-side communication of
  60. extension parameters can be used. Please see the implementations of different
  61. renderers for examples.