SpreadJS Documentation > Developer's Guide > Managing the User Interface > Using a Slicer > Creating a Custom Slicer |
You can create a custom slicer with the GeneralSlicerData class or the TableSlicerData class.
The GeneralSlicerData class is used to process data for a two-dimensional array. The class provides properties and methods that you can use to filter the data and get the filtered result. You can attach multiple slicers to a custom slicer. Each slicer can filter one column of data. After the filter is complete, the other slicers are notified by the GeneralSlicerData class. The slicers then can get the filtered result from GeneralSlicerData and update their UI.
The slicer works with the GeneralSlicerData class based on the following steps:
You can get all the data for a specific column with the getData method. You can get exclusive (non-repeating data) with the getExclusiveData method. You can filter a column with the doFilter method or clear the filter information with the doUnfilter method. For a complete list of methods, refer to the GeneralSlicerData class.
You can attach a listener to GeneralSlicerData with the attachListener function and detach it with the detachListener function.
The following image displays a custom slicer.
This example creates a custom slicer.
JavaScript |
Copy Code
|
---|---|
<!DOCTYPE html> <script type="text/javascript"> //Define custom slicer. //Define the show filtered result method. $(document).ready(function () { </head> |
This example creates a custom slicer and uses the TableSlicerData class for data.
JavaScript |
Copy Code
|
---|---|
<!DOCTYPE html> //Define custom slicer. }); $(document).ready(function () { //create a custom slicer and add this slicer to the "slicerContainer" div. }); </head> |