Filter datasource using a GUID

2 posts, 0 answers
  1. Edward
    Edward avatar
    29 posts
    Member since:
    Aug 2014

    Posted 08 Sep 2014 Link to this post

    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?
  2. Edward
    Edward avatar
    29 posts
    Member since:
    Aug 2014

    Posted 08 Sep 2014 in reply to Edward Link to this post

    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.

    :(
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top