Django ListView – Form to filter and sort

You don’t need post. Pass the filter value and order_by in the url for example: …/update/list/?filter=filter-val&orderby=order-val and get the filter and orderby in the get_queryset like: class MyView(ListView): model = Update template_name = “updates/update.html” paginate_by = 10 def get_queryset(self): filter_val = self.request.GET.get(‘filter’, ‘give-default-value’) order = self.request.GET.get(‘orderby’, ‘give-default-value’) new_context = Update.objects.filter( state=filter_val, ).order_by(order) return new_context def … Read more

In WPF Stretch a control to fill a ListView Column

After narrowing down my question I was about to Google and find an answer here. Basically for some reason the ListViewItems are set to align to the Left. Setting them to Stretch fixes this problem. This is done through a style like so: <ListView.ItemContainerStyle> <Style TargetType=”ListViewItem”> <Setter Property=”HorizontalContentAlignment” Value=”Stretch” /> </Style> </ListView.ItemContainerStyle> This unfortunately affects … Read more

How to maintain the state of widget in ListView?

Add the AutomaticKeepAliveClientMixin mixin to your State of your StatefulWidget (Item widget), override the wantKeepAlive method and return true. class _MarkWidgetState extends State<MarkWidget> with AutomaticKeepAliveClientMixin{ … @override Widget build(BuildContext context) { // call this method. super.build(context); … } @override bool get wantKeepAlive => true; } More info here: https://docs.flutter.io/flutter/widgets/AutomaticKeepAliveClientMixin-mixin.html

Alternate background color in Listview XAML

I tried this and it works for me. <Window x:Class=”TryResponses.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:vm=”clr-namespace:TryResponses” xmlns:system=”clr-namespace:System;assembly=mscorlib” Title=”MainWindow” Height=”350″ Width=”525″> <Window.Resources> <vm:MainWindowViewModel x:Key=”MainWindowViewModel” /> </Window.Resources> <Grid Background=”LightGray” DataContext=”{StaticResource MainWindowViewModel}”> <Grid.Resources> <Style TargetType=”ListViewItem”> <Style.Triggers> <Trigger Property=”ItemsControl.AlternationIndex” Value=”0″> <Setter Property=”Background” Value=”LightBlue” /> </Trigger> <Trigger Property=”ItemsControl.AlternationIndex” Value=”1″> <Setter Property=”Background” Value=”LightGray” /> </Trigger> </Style.Triggers> </Style> <DataTemplate DataType=”system:String”> <!– put your data template … Read more