@@ -319,9 +319,12 @@ def disable():
319319 enable (dataframe = False , series = False )
320320
321321
322- def show_grid (data_frame , show_toolbar = None ,
323- precision = None , grid_options = None ,
324- column_options = None , column_definitions = None ,
322+ def show_grid (data_frame ,
323+ show_toolbar = None ,
324+ precision = None ,
325+ grid_options = None ,
326+ column_options = None ,
327+ column_definitions = None ,
325328 row_edit_callback = None ):
326329 """
327330 Renders a DataFrame or Series as an interactive qgrid, represented by
@@ -428,13 +431,34 @@ class QgridWidget(widgets.DOMWidget):
428431 Whether to show a toolbar with options for adding/removing rows.
429432 Adding/removing rows is an experimental feature which only works
430433 with DataFrames that have an integer index.
434+ column_options : dict
435+ Column options that are to be applied to every column. See the
436+ Notes section below for more information on the available options,
437+ as well as the default options that this widget uses.
438+ column_definitions : dict
439+ Column options that are to be applied to individual
440+ columns. The keys of the dict should be the column names, and each
441+ value should be the column options for a particular column,
442+ represented as a dict. The available options for each column are the
443+ same options that are available to be set for all columns via the
444+ ``column_options`` parameter. See the Notes section below for more
445+ information on those options.
446+ row_edit_callback : callable
447+ A callable that is called to determine whether a particular row
448+ should be editable or not. Its signature should be
449+ ``callable(row)``, where ``row`` is a dictionary which contains a
450+ particular row's values, keyed by column name. The callback should
451+ return True if the provided row should be editable, and False
452+ otherwise.
453+
431454
432455 Notes
433456 -----
434457 The following dictionary is used for ``grid_options`` if none are
435458 provided explicitly::
436459
437460 {
461+ # SlickGrid options
438462 'fullWidthRows': True,
439463 'syncColumnCellResize': True,
440464 'forceFitColumns': True,
@@ -445,6 +469,8 @@ class QgridWidget(widgets.DOMWidget):
445469 'editable': True,
446470 'autoEdit': False,
447471 'explicitInitialization': True,
472+
473+ # Qgrid options
448474 'maxVisibleRows': 15,
449475 'minVisibleRows': 8,
450476 'sortable': True,
@@ -453,37 +479,59 @@ class QgridWidget(widgets.DOMWidget):
453479 'highlightSelectedRow': True
454480 }
455481
456- Most of these options are SlickGrid options which are described
457- in the `SlickGrid documentation
458- <https://github.com/mleibman/SlickGrid/wiki/Grid-Options>`_. The
459- exceptions are the last 6 options listed, which are options that were
460- added specifically for Qgrid and therefore are not documented in the
461- SlickGrid documentation.
462-
463- The first two, `maxVisibleRows` and `minVisibleRows`, allow you to set
464- an upper and lower bound on the height of your Qgrid widget in terms of
465- number of rows that are visible.
466-
467- The next two, `sortable` and `filterable`, control whether qgrid will
468- allow the user to sort and filter, respectively. If you set `sortable` to
469- False nothing will happen when the column headers are clicked.
470- If you set `filterable` to False, the filter icons won't be shown for any
471- columns.
472-
473- The last two, `highlightSelectedCell` and `highlightSelectedRow`, control
474- how the styling of qgrid changes when a cell is selected. If you set
475- `highlightSelectedCell` to True, the selected cell will be given
476- a light blue border. If you set `highlightSelectedRow` to False, the
477- light blue background that's shown by default for selected rows will be
478- hidden.
482+ The first group of options are SlickGrid "grid options" which are
483+ described in the `SlickGrid documentation
484+ <https://github.com/mleibman/SlickGrid/wiki/Grid-Options>`_.
485+
486+ The second group of option are options that were added specifically
487+ for Qgrid and therefore are not documented in the SlickGrid documentation.
488+ The following bullet points describe these options.
489+
490+ * **maxVisibleRows** The maximum number of rows that Qgrid will show.
491+ * **minVisibleRows** The minimum number of rows that Qgrid will show
492+ * **sortable** Whether the Qgrid instance will allow the user to sort
493+ columns by clicking the column headers. When this is set to ``False``,
494+ nothing will happen when users click the column headers.
495+ * **filterable** Whether the Qgrid instance will allow the user to filter
496+ the grid. When this is set to ``False`` the filter icons won't be shown
497+ for any columns.
498+ * **highlightSelectedCell** If you set this to True, the selected cell
499+ will be given a light blue border.
500+ * **highlightSelectedRow** If you set this to False, the light blue
501+ background that's shown by default for selected rows will be hidden.
502+
503+ The following dictionary is used for ``column_options`` if none are
504+ provided explicitly::
505+
506+ {
507+ # SlickGrid column options
508+ 'defaultSortAsc': True,
509+ 'maxWidth': None,
510+ 'minWidth': 30,
511+ 'resizable': True,
512+ 'sortable': True,
513+ 'toolTip': "",
514+ 'width': None
515+
516+ # Qgrid column options
517+ 'editable': True,
518+ }
519+
520+ The first group of options are SlickGrid "column options" which are
521+ described in the `SlickGrid documentation
522+ <https://github.com/mleibman/SlickGrid/wiki/Column-Options>`_.
523+
524+ The ``editable`` option was added specifically for Qgrid and therefore is
525+ not documented in the SlickGrid documentation. This option specifies
526+ whether a column should be editable or not.
479527
480528 See Also
481529 --------
482530 set_defaults : Permanently set global defaults for the parameters
483531 of the QgridWidget constructor, with the exception of
484- the ``df`` parameter.
532+ the ``df`` and the ``column_definitions`` parameter.
485533 set_grid_option : Permanently set global defaults for individual
486- SlickGrid options. Does so by changing the default
534+ grid options. Does so by changing the default
487535 for the ``grid_options`` parameter of the QgridWidget
488536 constructor.
489537
@@ -496,11 +544,16 @@ class QgridWidget(widgets.DOMWidget):
496544 does reflect sorting/filtering/editing changes, use the
497545 ``get_changed_df()`` method.
498546 grid_options : dict
499- Get/set the SlickGrid options being used by the current instance.
547+ Get/set the grid options being used by the current instance.
500548 precision : integer
501549 Get/set the precision options being used by the current instance.
502550 show_toolbar : bool
503551 Get/set the show_toolbar option being used by the current instance.
552+ column_options : bool
553+ Get/set the column options being used by the current instance.
554+ column_definitions : bool
555+ Get/set the column definitions (column-specific options)
556+ being used by the current instance.
504557
505558 """
506559
@@ -543,7 +596,7 @@ class QgridWidget(widgets.DOMWidget):
543596 df = Instance (pd .DataFrame )
544597 precision = Integer (6 , sync = True )
545598 grid_options = Dict (sync = True )
546- column_options = Dict (sync = True )
599+ column_options = Dict ({} )
547600 column_definitions = Dict ({})
548601 row_edit_callback = Instance (FunctionType , sync = False , allow_none = True )
549602 show_toolbar = Bool (False , sync = True )
@@ -649,12 +702,16 @@ def on(self, names, handler):
649702 in the grid toolbar.
650703
651704 * **index** The index of the newly added row.
705+ * **source** The source of this event. Possible values are
706+ ``api`` (an api method call) and ``gui`` (the grid interface).
652707
653708 * **row_removed** The user added removed one or more rows using the
654709 "Remove Row" button in the grid toolbar.
655710
656711 * **indices** The indices of the removed rows, specified as an
657712 array of integers.
713+ * **source** The source of this event. Possible values are
714+ ``api`` (an api method call) and ``gui`` (the grid interface).
658715
659716 * **selection_changed** The user changed which rows were highlighted
660717 in the grid.
@@ -663,6 +720,8 @@ def on(self, names, handler):
663720 selected rows.
664721 * **new** The indices of the rows that are now selected, again
665722 specified as an array.
723+ * **source** The source of this event. Possible values are
724+ ``api`` (an api method call) and ``gui`` (the grid interface).
666725
667726 * **sort_changed** The user changed the sort setting for the grid.
668727
0 commit comments