File tree Expand file tree Collapse file tree 2 files changed +38
-10
lines changed
src/BootstrapBlazor.Server/Components/Samples Expand file tree Collapse file tree 2 files changed +38
-10
lines changed Original file line number Diff line number Diff line change 173173<DemoBlock Title =" @Localizer[" TreeViewShowSearchTitle " ]"
174174 Introduction =" @Localizer[" TreeViewShowSearchIntro " ]"
175175 Name =" ShowSearch" >
176- <TreeView TItem =" TreeFoo" Items =" @SearchItems " ShowSearch =" true" OnSearchAsync =" @OnSearchAsync " ></TreeView >
176+ <TreeView TItem =" TreeFoo" Items =" @SearchItems1 " ShowSearch =" true" OnSearchAsync =" @OnSearch1Async " ></TreeView >
177177</DemoBlock >
178178
179179<DemoBlock Title =" @Localizer[" TreeViewFixedSearchTitle " ]"
180180 Introduction =" @Localizer[" TreeViewFixedSearchIntro " ]"
181181 Name =" IsFixedSearch" >
182- <TreeView TItem =" TreeFoo" Items =" @SearchItems " ShowSearch =" true" OnSearchAsync =" @OnSearchAsync " IsFixedSearch =" true" style =" height : 180px ;" ></TreeView >
182+ <TreeView TItem =" TreeFoo" Items =" @SearchItems2 " ShowSearch =" true" OnSearchAsync =" @OnSearch2Async " IsFixedSearch =" true" style =" height : 180px ;" ></TreeView >
183183</DemoBlock >
184184
185185<DemoBlock Title =" @Localizer[" TreeViewMaxSelectedCountTitle " ]"
186186 Introduction =" @Localizer[" TreeViewMaxSelectedCountIntro " ]"
187187 Name =" MaxSelectedCount" >
188188 <section ignore >@( (MarkupString )Localizer [" TreeViewMaxSelectedCountDesc" ].Value ) </section >
189- <TreeView TItem =" TreeFoo" Items =" @SearchItems " ShowCheckbox =" true" AutoCheckChildren =" true" AutoCheckParent =" true"
189+ <TreeView TItem =" TreeFoo" Items =" @MaxItems " ShowCheckbox =" true" AutoCheckChildren =" true" AutoCheckParent =" true"
190190 MaxSelectedCount =" 2" OnMaxSelectedCountExceed =" OnMaxSelectedCountExceed" ></TreeView >
191191</DemoBlock >
192192
193193<DemoBlock Title =" @Localizer[" TreeViewEnableKeyboardArrowUpDownTitle " ]"
194194 Introduction =" @Localizer[" TreeViewEnableKeyboardArrowUpDownIntro " ]"
195- Name =" Normal " >
195+ Name =" EnableKeyboard " >
196196 <section ignore >@_selectedValue </section >
197197 <TreeView TItem =" TreeFoo" Items =" @KeyboardItems" OnTreeItemClick =" @OnTreeItemKeyboardClick" style =" height : 160px ;"
198198 EnableKeyboard =" true" ClickToggleNode =" false" ClickToggleCheck =" false" ShowCheckbox =" true" />
Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ public sealed partial class TreeViews
5353
5454 private List < TreeViewItem < TreeFoo > > ? AsyncItems { get ; set ; }
5555
56- private List < TreeViewItem < TreeFoo > > ? SearchItems { get ; set ; } = TreeFoo . GetTreeItems ( ) ;
56+ private List < TreeViewItem < TreeFoo > > ? MaxItems { get ; set ; } = TreeFoo . GetTreeItems ( ) ;
57+
58+ private List < TreeViewItem < TreeFoo > > ? SearchItems1 { get ; set ; } = TreeFoo . GetTreeItems ( ) ;
59+
60+ private List < TreeViewItem < TreeFoo > > ? SearchItems2 { get ; set ; } = TreeFoo . GetTreeItems ( ) ;
5761
5862 private List < TreeViewItem < TreeFoo > > VirtualizeItems { get ; } = TreeFoo . GetVirtualizeTreeItems ( ) ;
5963
@@ -226,12 +230,36 @@ private Task SelectedItemOnChanged(SelectedItem selectedItem)
226230 return ret ;
227231 }
228232
229- private Task OnSearchAsync ( string searchText )
233+ private Task OnSearch1Async ( string searchText )
230234 {
231- SearchItems =
232- [
233- new TreeViewItem < TreeFoo > ( new TreeFoo ( ) { Text = searchText } ) { Text = searchText } ,
234- ] ;
235+ if ( string . IsNullOrEmpty ( searchText ) )
236+ {
237+ SearchItems1 = TreeFoo . GetTreeItems ( ) ;
238+ }
239+ else
240+ {
241+ SearchItems1 =
242+ [
243+ new TreeViewItem < TreeFoo > ( new TreeFoo ( ) { Text = searchText } ) { Text = searchText } ,
244+ ] ;
245+ }
246+ StateHasChanged ( ) ;
247+ return Task . CompletedTask ;
248+ }
249+
250+ private Task OnSearch2Async ( string searchText )
251+ {
252+ if ( string . IsNullOrEmpty ( searchText ) )
253+ {
254+ SearchItems1 = TreeFoo . GetTreeItems ( ) ;
255+ }
256+ else
257+ {
258+ SearchItems2 =
259+ [
260+ new TreeViewItem < TreeFoo > ( new TreeFoo ( ) { Text = searchText } ) { Text = searchText } ,
261+ ] ;
262+ }
235263 StateHasChanged ( ) ;
236264 return Task . CompletedTask ;
237265 }
You can’t perform that action at this time.
0 commit comments