Telerik Forums
UI for ASP.NET MVC Forum
1 answer
492 views

 When using "Filter Multi Checkboxes "  I get an error saying cannot convert CompositeFilterDescriptor

 to FilterDescriptor . on this line "For Each filterDescriptor As FilterDescriptor In request.Filters"

I understand the error, but  how to get around it,

thanks

 

Imports Kendo.Mvc
Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports System.Data.Entity
 
Namespace Models.Students
    Public Class StudentGridModel
        Public Property PageSize As Integer = 25
        Private _Students As ReadOnlyCollection(Of BO.Models.Students.Student)
        <System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")> Public Property Students As ReadOnlyCollection(Of BO.Models.Students.Student)
            Get
                Return _Students
            End Get
            Set(value As ReadOnlyCollection(Of BO.Models.Students.Student))
                _Students = value
            End Set
        End Property
 
        Public Property Total As Integer
 
        Sub New()
            Using db As EF.GrasshopperEntities = New EF.GrasshopperEntities
                Me._Students = New ReadOnlyCollection(Of BO.Models.Students.Student)(db.Students.Include(Function(i) i.Franchisee).OrderBy(Function(o) o.StudentId).Take(Me.PageSize).AsEnumerable.Select(Function(s) New BO.Models.Students.Student With {
                                .FirstName = s.FirstName,
                                .FranchiseeName = s.Franchisee.Name,
                                .LastName = s.LastName,
                                .Age = s.Age,
                                .Birthday = s.Birthday,
                                .Female = s.Female,
                                .Suburb = s.Suburb,
                                .PhoneNumber = s.PhoneNumber,
                                .MobileNumber = s.MobileNumber,
                                .Email = s.Email,
                                .TotalSales = s.Sales(),
                                .ProductSales = s.Sales(Function(t) Not t.ProductId.Equals(0)),
                                .EnrolmentSales = s.Sales(Function(t) Not t.EnrolmentId.Equals(0)),
                                .EventSales = s.Sales(Function(t) Not t.StudentEventId.Equals(0)),
                                .StudentId = s.StudentId}).ToList)
                Me.Total = db.Students.Count
            End Using
 
        End Sub
 
        Sub New(request As UI.DataSourceRequest)
            Using db As EF.GrasshopperEntities = New EF.GrasshopperEntities
                Me._Students = New ReadOnlyCollection(Of BO.Models.Students.Student)(GetData(request, Me.Total))
            End Using
        End Sub
 
        ''' <summary>
        ''' Reterns student data for kendo grid
        ''' </summary>
        ''' <param name="request">Kendo.Mvc.UI.DataSourceRequest</param>
        ''' <param name="Total">Integer</param>
        ''' <returns>ReadOnlyCollection(Of BO.Models.Students.students)</returns>
        ''' <remarks></remarks>
        Private Shared Function GetData(ByVal request As Kendo.Mvc.UI.DataSourceRequest, ByRef total As Integer) As ReadOnlyCollection(Of BO.Models.Students.Student)
            Using db As EF.GrasshopperEntities = New EF.GrasshopperEntities
                Dim data As IQueryable(Of EF.Student) = db.Students.Include(Function(i) i.Franchisee)
                If Not request.Sorts Is Nothing AndAlso request.Sorts.Any Then
                    For Each sortDescriptor As SortDescriptor In request.Sorts
                        data = SortStudent(sortDescriptor, data)
                    Next
                Else
                    data = data.OrderBy(Function(o) o.StudentId)
                End If
 
                If request.Filters.Any() Then
                    Dim filterValue As String = String.Empty
                    For Each filterDescriptor As FilterDescriptor In request.Filters
 
                        Select Case filterDescriptor.Member
                            Case "FranchiseeName"
                                filterValue = CStr(filterDescriptor.ConvertedValue)
                                Select Case filterDescriptor.Operator
                                    Case FilterOperator.Contains
                                        data = data.Where(Function(w) w.Franchisee.Name.Contains(filterValue))
                                    Case FilterOperator.DoesNotContain
                                        data = data.Where(Function(w) Not w.Franchisee.Name.Contains(filterValue))
                                    Case FilterOperator.EndsWith
                                        data = data.Where(Function(w) w.Franchisee.Name.EndsWith(filterValue))
                                    Case FilterOperator.IsEqualTo
                                        data = data.Where(Function(w) w.Franchisee.Name.Equals(filterValue))
                                    Case FilterOperator.IsNotEqualTo
                                        data = data.Where(Function(w) Not w.Franchisee.Name.Equals(filterValue))
                                    Case FilterOperator.StartsWith
                                        data = data.Where(Function(w) w.Franchisee.Name.StartsWith(filterValue))
                                End Select
                        End Select
                    Next
                End If
                If request.Filters.Any() Then
                    data = data.Where(ExpressionBuilder.Expression(Of EF.Student)(request.Filters))
                End If
                total = data.Count
 
                If request.PageSize > 0 Then
                    data = data.Skip((request.Page - 1) * request.PageSize)
                    data = data.Take(request.PageSize)
                End If
                Return New ReadOnlyCollection(Of BO.Models.Students.Student)(data.AsEnumerable.Select(Function(s) New BO.Models.Students.Student With {
                                        .FranchiseeName = s.Franchisee.Name,
                                        .FirstName = s.FirstName,
                                        .LastName = s.LastName,
                                        .Age = s.Age,
                                        .Birthday = s.Birthday,
                                        .Female = s.Female,
                                        .Suburb = s.Suburb,
                                        .PhoneNumber = s.PhoneNumber,
                                        .MobileNumber = s.MobileNumber,
                                        .Email = s.Email,
                                        .TotalSales = s.Sales(),
                                        .ProductSales = s.Sales(Function(t) Not t.ProductId.Equals(0)),
                                        .EnrolmentSales = s.Sales(Function(t) Not t.EnrolmentId.Equals(0)),
                                        .EventSales = s.Sales(Function(t) Not t.StudentEventId.Equals(0)),
                                        .StudentId = s.StudentId}).ToList)
            End Using
 
        End Function
 
        Private Shared Function SortStudent(sortDescriptor As SortDescriptor, data As IQueryable(Of EF.Student)) As IQueryable(Of EF.Student)
            If sortDescriptor.SortDirection.Equals(ListSortDirection.Ascending) Then
                Select Case sortDescriptor.Member
                    Case "StudentId"
                        data = data.OrderBy(Function(o) o.StudentId)
                    Case "FranchiseeName"
                        data = data.OrderBy(Function(o) o.Franchisee.Name)
                    Case "FirstName"
                        data = data.OrderBy(Function(o) o.FirstName)
                    Case "LastName"
                        data = data.OrderBy(Function(o) o.LastName)
                    Case "Age"
                        data = data.OrderBy(Function(o) o.Birthday)
                    Case "Female"
                        data = data.OrderBy(Function(o) o.Female)
                    Case "Suburb"
                        data = data.OrderBy(Function(o) o.Suburb)
                End Select
            Else
                Select Case sortDescriptor.Member
                    Case "StudentId"
                        data = data.OrderByDescending(Function(o) o.StudentId)
                    Case "FranchiseeName"
                        data = data.OrderByDescending(Function(o) o.Franchisee.Name)
                    Case "FirstName"
                        data = data.OrderByDescending(Function(o) o.FirstName)
                    Case "LastName"
                        data = data.OrderByDescending(Function(o) o.LastName)
                    Case "Age"
                        data = data.OrderByDescending(Function(o) o.Birthday)
                    Case "Female"
                        data = data.OrderByDescending(Function(o) o.Female)
                    Case "Suburb"
                        data = data.OrderByDescending(Function(o) o.Suburb)
                End Select
            End If
            Return data
        End Function
    End Class
End Namespace
 

 

 

Atanas Korchev
Telerik team
 answered on 13 Jul 2015
1 answer
109 views

I have a grid with multiple ForeignKey columns which work nicely however i'd like to be able to set up some column dependencies.

Is the above possible to have a child ForeignKey column either updated or filtered based on the selected value of the parent ForeignKey column?

Ideally i'd like to call an action on change as the initial data is generated in the controller.

So far I've not been able to find an example that does all of the above.

Thanks

Graeme

Vladimir Iliev
Telerik team
 answered on 13 Jul 2015
1 answer
226 views

Hello,

Is it possible to format the urlTemplate in such a way that we can connect a layer of type Tile to a Web Mapping Server?

The problem seems to be fulfilling the BBOX parameter that the WMS Standard expects.

If not, could you please suggest a suitable work-around one can implement to get the Layers from a WMS integrated?

Regards,

Aaron

T. Tsonev
Telerik team
 answered on 10 Jul 2015
1 answer
108 views

Hi!  I'm wondering how one can upload asynchronously given the following:

     -- Auto upload is false

     -- User clicks an upload button to initiate the upload via ajax WITHOUT doing a form post.

Thanks!

Dimiter Madjarov
Telerik team
 answered on 10 Jul 2015
1 answer
82 views

Is there a way to "Select All" users in the editor popup?

I'm using .AutoClose(false), but that's not enough for the client. They want to select all users.

I'm using editable.TemplateName("CustomEditorTemplate");

Vladimir Iliev
Telerik team
 answered on 10 Jul 2015
1 answer
447 views
Is there a way to remove the top border from the NumericTextBox? I have already removed the spinner but I need the top border gone and any padding.
Plamen Lazarov
Telerik team
 answered on 09 Jul 2015
2 answers
96 views
I tried to upload a zip file through "attach files". But it failed to be uploaded and each time connection were lost in uploading. What is the problem?
york
Top achievements
Rank 1
 answered on 09 Jul 2015
2 answers
121 views
Hi,

I want to edit and display in a kendo window a time property (format HH:mm). 
I started with the Time editor and with a DateTime attribute, but the value to be biended is not displayed in the form.
How can we fix it ?
Apparently the Timepicker supports a TimeSpan value, but Javascript doesn't support Timespan (json serialization problems).
ex : @Html.EditorFor(m => m.StartTime, "Time")

Thanks for your help
Stephane
Top achievements
Rank 1
 answered on 08 Jul 2015
1 answer
387 views
I'm trying to add a custom button on a TreeList Toolbar.   I can see that .Toolbar (t=>t.Custom().Text("My Action")) is exactly what I'm looking for, however what is not obvious is how to add the action.   For the Grid, it would be .Toolbar(t=>t.Custom().Action("Action", "Controller").Text("My Action").   Why does TreeList have similiar behaviour?
Dimiter Madjarov
Telerik team
 answered on 08 Jul 2015
1 answer
177 views
I have been able to successfully build an integrate a Custom Editor Template for the events in the scheduler. However, There are certain fields in the Model being edited that I only want to display- the user should not be able to edit the values. I also want to include a button inside of the Custom Editor that links to another area of the web app based off of one of these readonly Model properties. However, I have been having issues getting these readonly properties to properly bind to the view... I have tried Html.DisplayFor, and this is not binding correctly. How can I properly bind and access the values for Model properties inside of a Custom Editor while keeping the values read-only?
Vladimir Iliev
Telerik team
 answered on 08 Jul 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?