Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 99250

JumpList in DataForm

$
0
0
Hello, thanks for the template. It is very helpful.

Below is my attempt at using the template to accomplish the filtering functionality. This code "works" but is not very reusable. The filtering currently is being done at the page level, not as a custom editor.

I am not seeing a way to refactor this functionality into a custom editor, due to the following.

-Can't see a way to use the template you provided as a part of a user control/custom editor.
-Don't see a way to "get at" the associated RadDataField properties (to determine bindings, i.e. which IGenericListFieldInfoProvider is associated with the bound field on my model [GenericListEditor])

I am hoping to use this functionality in all of my list driven dataform fields, but my current approach is inelegant. Any suggestions on how to get this into a custom editor?

Thanks
-Rob

FirstLook.xaml
                        <telerikPrimitives:RadWindow.Content>
                            <Grid 
                                    Background="{StaticResource PhoneChromeBrush}"
                                    telerikCore:RadTileAnimation.ContainerToAnimate="{Binding ElementName=PopupList, Path=.}">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <ContentControl Grid.Row="0" CacheMode="BitmapCache"
                                            Content="{TemplateBinding PopupHeader}"
                                            ContentTemplate="{TemplateBinding PopupHeaderTemplate}"
                                            Style="{TemplateBinding PopupHeaderStyle}" />
                                <telerikPrimitives:RadTextBox Grid.Row="1" x:Name="search" Watermark="search" TextChanged="search_TextChanged"/>
                                <telerikData:RadJumpList Grid.Row="2" x:Name="PopupList"
                                            telerikCore:InteractionEffectManager.IsInteractionEnabled="True"
                                            Style="{TemplateBinding PopupStyle}"
                                            IsCheckModeActive="False"
                                            DisplayMemberPath="{TemplateBinding DisplayMemberPath}"
                                            ItemContainerStyle="{TemplateBinding PopupItemStyle}"
                                            CheckModeDeactivatedOnBackButton="False" >
                                </telerikData:RadJumpList>
                            </Grid>
                        </telerikPrimitives:RadWindow.Content>



Firstlook.xml.cs

        Dictionary<String, IEnumerable> masterlists = new Dictionary<string, IEnumerable>();
        
        private void search_TextChanged(object sender, TextChangedEventArgs e)
        {
            // the textbox text changed (user is "filtering" the list)
            RadTextBox searchbox = (RadTextBox)sender;
            // the text that the user typed
            String filter = searchbox.Text.ToUpper();

            // try to find the jumplist
            RadJumpList jumplist = (RadJumpList)searchbox.FindName("PopupList");

            // try to find the header, I will use this to try to track the full list, before filtering
            ContentControl header = (ContentControl)searchbox.FindName("HeaderPresenter");
            String listid = header.Content.ToString();

            // keep track of all "full lists" (need to do this because user may backspace in the TextBox and will need to restore the list to what it was originally, prior to filtering)
            if (masterlists.ContainsKey(listid) == false)
            {
                masterlists[listid] = jumplist.ItemsSource;
            }

            // filter based on what was typed in the text box
            var temp = masterlists[listid];
            List<String> filtered = new List<string>();
            foreach(var x in temp)
            {
                if (x.ToString().ToUpper().StartsWith(filter))
                    filtered.Add(x.ToString());
            }
            jumplist.ItemsSource = filtered;
        }



Viewing all articles
Browse latest Browse all 99250