关于SpreadJs的筛选,按照之前的做法(需要筛选的区域数据是做在模板中,在加载画面时,在Js侧动态加载筛选功能)中,能够实现筛选功能以及默认选中指定内容。
但是随着客户需求的变更,要求筛选区域的数据是动态加载的,在加载完之后加入筛选功能,并设定默认表示区域。在这种情况下,默认选中的功能却实现不了了,希望各位大神能够提供帮助。
代码如下
- <script type="text/javascript">
- $(document).ready(function(){
- var workbook = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
- $("#test1").click(function(){
- var sheet = workbook.getSheetFromName("Sheet1");
- sheet.setValue(3,3,"AAAAA",GC.Spread.Sheets.SheetArea.viewport);
- sheet.setValue(4,3,"BBBBB",GC.Spread.Sheets.SheetArea.viewport);
- sheet.setValue(5,3,"AAAAA",GC.Spread.Sheets.SheetArea.viewport);
- sheet.setValue(6,3,"CCCCC",GC.Spread.Sheets.SheetArea.viewport);
- sheet.setValue(7,3,"AAAAA",GC.Spread.Sheets.SheetArea.viewport);
- var tableStyle = GC.Spread.Sheets.Tables.TableThemes.light1;
- var table = sheet.tables.add("hello",2,3,6,1,tableStyle);
- var rowfilter = sheet.tables.findByName("hello").rowFilter();
- rowfilter.filterDialogVisibleInfo({
- sortByValue: false,
- sortByColor: false,
- filterByColor:false,
- filterByValue: false,
- listFilterArea:true
- });
- var tableRowfilter = sheet.tables.findByName("hello").rowFilter();
- var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition,{
- compareType:0,
- conType:2,
- expected:"AAAAA",
- useWildCards:false
- });
- var condition1 = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition,{
- compareType:0,
- conType:2,
- expected:"CCCCC",
- useWildCards:false
- });
- tableRowfilter.addFilterItem(0,condition);
- tableRowfilter.addFilterItem(0,condition1);
- tableRowfilter.filter(0);
- workbook.refresh();
- });
- });
- </script>
复制代码
想实现的功能是,在点击test1按钮时,现在指定单元格赋值,之后再给指定区域追加筛选功能,最后设定默认选中“AAAAA”和“CCCCC”
|