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

removing an item from doesn't remove from list

5 Answers 134 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Gregory
Top achievements
Rank 1
Gregory asked on 18 Nov 2015, 12:05 AM

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!

5 Answers, 1 is accepted

Sort by
0
Gregory
Top achievements
Rank 1
answered on 18 Nov 2015, 12:20 AM
It seems the EndlessScroll property is causing this.  Any suggestions? I'll keep testing.
0
Gregory
Top achievements
Rank 1
answered on 18 Nov 2015, 05:08 PM

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

 

0
Gregory
Top achievements
Rank 1
answered on 20 Nov 2015, 06:23 PM
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?
0
Gregory
Top achievements
Rank 1
answered on 20 Nov 2015, 07:59 PM
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?
0
Atanas Korchev
Telerik team
answered on 23 Nov 2015, 07:10 AM
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
Tags
ListView (Mobile)
Asked by
Gregory
Top achievements
Rank 1
Answers by
Gregory
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or