removing an item from doesn't remove from list

6 posts, 0 answers
  1. Gregory
    Gregory avatar
    14 posts
    Member since:
    Feb 2014

    Posted 17 Nov 2015 Link to this post

    Anyone know why when I remove an item from my datasource it removes it from my database, but not my Mobile List View? Below is basically what I'm doing:

                model = dataSource.getByUid($(e.touch.target).attr("data-uid"));
                dataSource.remove(model);
                dataSource.sync();

     

    I got this from the mobilelistview sample app and it works correctly, just not with my modified mobile list view. Could it be because of a filter I have or my type of model or something? Here is the Mobile list view control section:

    Html.Kendo().MobileListView<eAgentWeb.Models.CallLogModel>()
                        .Name("MainListView")
                        .TemplateId("itemTemplate")
                        .PullToRefresh(true)
                        .EndlessScroll(true)
                        .DataSource(dataSource => dataSource
                            .Sort(sort => sort.Add("DateModified").Descending())
                            .Filter(filters => { filters.Add(calllog => calllog.IsArchive).IsEqualTo(false); })
                            .Read(read => read.Action("GetCallLogData", "CallLog"))
                            .Destroy("callLog_Destroy", "CallLog")
                            .PageSize(30)
                            .Events(events => events.RequestEnd("listViewRequestEnd"))
                            .Model(model => model.Id(c => c.CallLogID))
                        )
                    )
    )

     

    Any help would be greatly appreciated!

  2. Gregory
    Gregory avatar
    14 posts
    Member since:
    Feb 2014

    Posted 17 Nov 2015 Link to this post

    It seems the EndlessScroll property is causing this.  Any suggestions? I'll keep testing.
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Gregory
    Gregory avatar
    14 posts
    Member since:
    Feb 2014

    Posted 18 Nov 2015 Link to this post

    I added a listview.refresh() method call. This works, but is it overkill?

     

  5. Gregory
    Gregory avatar
    14 posts
    Member since:
    Feb 2014

    Posted 20 Nov 2015 Link to this post

    Having an additional problem. I'm trying to check if another user updated the record before my user can delete it. I'm trying to add an error item to the modelstate and then handle that error in a datasource sync event. If there is an error I read and refresh the datasource. So the user will see the updated record. However, the second time my user tries to delete something it seems to trigger the datasource sync method multiple times (depending on how many times I tried deleting a record without manually refreshing).  I hope my issue makes sense.  Please let me know if you would like me to elaborate further. Am I going about handling concurrency issues the right way?
  6. Gregory
    Gregory avatar
    14 posts
    Member since:
    Feb 2014

    Posted 20 Nov 2015 Link to this post

    Additionally, I'm not really deleting a record. I'm just flagging it Inactive in my db then filtering inactives out...  Could that have something do with the destroy event causing this? Should I be using the Update event?
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 23 Nov 2015 Link to this post

    Hello Gregory,

    You could try using the error event of the data source to check for model state errors. Here is some code which does that (it is taken from a grid example but should work with the mobile listview)


    function onerror(e) {
        if (e.errors) {
            var message = "There are some errors:\n";
            // Create a message containing all errors.
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            // Display the message
            alert(message);
            this.read(); // read fresh data from the server
        }
    }

    If this doesn't solve the problem please send us either a live url where we can observe it or a sample project. Feel free to open a support ticket if the sample uses any confidential info.

    Regards,
    Atanas Korchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready