This is a migrated thread and some comments may be shown as answers.

Filter datasource using a GUID

1 Answer 185 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 08 Sep 2014, 02:06 PM
I'm getting an javascript error when trying to filter the scheduler using a Guid from a dropdownlist.  I had a very similar error when filtering by an int.  That was fixed by using parseInt(this.value)  instead of using this.value and then assigning the parseInt to  the filter value like:
var filter = {
                logic: "or",
                filters: [
                    {
                        operator: "eq",
                        field: "AssetID",
                        value: parseInt(this.value())
                    }
                ]
            };
 
Now I'm having the same type of error when the DataValueField of the dropdownlist is a Guid.

I'm doing this:
<div style="margin-left: 30px; margin-bottom: 20px">
    Choose Owner:
    @(Html.Kendo().DropDownList()
          .Name("Owner")
          .DataTextField("DisplayName")
          .DataValueField("UserID")
          .DataSource(ds => ds.Read("TaskUsers", "Users"))
          .Events(events => events.Change("userChange"))
    )
</div>
function userChange() {
 
    var scheduler = $("#scheduler").data("kendoScheduler");
 
    var selection = this.value();
     
    if (selection == "00000000-0000-0000-0000-000000000000") {
        scheduler.dataSource.filter([]);
    }
    else {
        var filter = {
            logic: "or",
            filters: [
                {
                    operator: "eq",
                    field: "AssetID",
                    value: selection
                }
            ]
        };
        scheduler.dataSource.filter(filter);
    }
}

I placed a break point in the code and 'selection' is a valid guid string and it is the guid that I expected it to be.
Can you filter by a Guid?

1 Answer, 1 is accepted

Sort by
0
Edward
Top achievements
Rank 1
answered on 08 Sep 2014, 02:21 PM
This is not an issue now.  I had the wrong field in the filter, it should have been OwnerID not AssetID.  Copy and Paste gets me every time.

:(
Tags
Scheduler
Asked by
Edward
Top achievements
Rank 1
Answers by
Edward
Top achievements
Rank 1
Share this question
or