@@ -155,6 +155,55 @@ const meta: Meta<typeof DataGrid> = {
155155 }
156156} ;
157157
158+ const columnChooserArgTypes : Partial < Meta < typeof DataGrid > [ 'argTypes' ] > = {
159+ 'columnChooser.enabled' : {
160+ control : 'boolean' ,
161+ } ,
162+ 'columnChooser.mode' : {
163+ control : 'radio' ,
164+ options : [ 'select' , 'dragAndDrop' ] ,
165+ } ,
166+ 'columnChooser.title' : {
167+ control : 'text' ,
168+ } ,
169+ 'columnChooser.height' : {
170+ control : 'number' ,
171+ } ,
172+ 'columnChooser.width' : {
173+ control : 'number' ,
174+ } ,
175+ 'columnChooser.sortOrder' : {
176+ control : 'radio' ,
177+ options : [ 'asc' , 'desc' , 'none' ] ,
178+ mapping : {
179+ asc : 'asc' ,
180+ desc : 'desc' ,
181+ none : undefined ,
182+ } ,
183+ } ,
184+ 'columnChooser.emptyPanelText' : {
185+ control : 'text' ,
186+ } ,
187+ 'columnChooser.container' : {
188+ control : 'text' ,
189+ } ,
190+ 'columnChooser.search.enabled' : {
191+ control : 'boolean' ,
192+ } ,
193+ 'columnChooser.search.timeout' : {
194+ control : 'number' ,
195+ } ,
196+ 'columnChooser.selection.allowSelectAll' : {
197+ control : 'boolean' ,
198+ } ,
199+ 'columnChooser.selection.recursive' : {
200+ control : 'boolean' ,
201+ } ,
202+ 'columnChooser.selection.selectByClick' : {
203+ control : 'boolean' ,
204+ } ,
205+ } ;
206+
158207export default meta ;
159208
160209type Story = StoryObj < typeof DataGrid > ;
@@ -353,3 +402,46 @@ export const AiColumn: Story = {
353402 allowColumnReordering : true ,
354403 } ,
355404} ;
405+
406+ export const ColumnChooserStory : Story = {
407+ name : 'ColumnChooser' ,
408+ argTypes : columnChooserArgTypes ,
409+ args : {
410+ 'columnChooser.enabled' : true ,
411+ 'columnChooser.mode' : 'select' ,
412+ 'columnChooser.title' : 'Choose Columns' ,
413+ 'columnChooser.height' : 300 ,
414+ 'columnChooser.width' : 250 ,
415+ 'columnChooser.sortOrder' : undefined ,
416+ 'columnChooser.emptyPanelText' : 'Drag a column here to hide it' ,
417+ 'columnChooser.search.enabled' : true ,
418+ 'columnChooser.search.timeout' : 0 ,
419+ 'columnChooser.selection.allowSelectAll' : true ,
420+ 'columnChooser.selection.recursive' : true ,
421+ 'columnChooser.selection.selectByClick' : true ,
422+ } ,
423+ render : ( args ) => (
424+ < DataGrid
425+ dataSource = { countries }
426+ keyExpr = "ID"
427+ showBorders = { true }
428+ allowColumnReordering = { true }
429+ { ...args }
430+ >
431+ < Column dataField = "ID" width = { 60 } />
432+ < Column dataField = "Country" />
433+ < Column dataField = "Area" caption = "Area, km²" format = "fixedPoint" />
434+ < Column caption = "Population" >
435+ < Column dataField = "Population_Total" caption = "Total" format = "fixedPoint" />
436+ < Column dataField = "Population_Urban" caption = "Urban" format = "percent" />
437+ < Column dataField = "Population_Rural" caption = "Rural" format = "percent" />
438+ </ Column >
439+ < Column caption = "GDP" >
440+ < Column dataField = "GDP_Total" caption = "Total, mln $" allowHiding = { false } format = "fixedPoint" />
441+ < Column dataField = "GDP_Agriculture" caption = "Agriculture" format = { { type : 'percent' , precision : 1 } } />
442+ < Column dataField = "GDP_Industry" caption = "Industry" format = { { type : 'percent' , precision : 1 } } />
443+ < Column dataField = "GDP_Services" caption = "Services" format = { { type : 'percent' , precision : 1 } } />
444+ </ Column >
445+ </ DataGrid >
446+ ) ,
447+ } ;
0 commit comments