Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MVC, WebAPI Controllers and LocalStorage
Message
De
04/07/2014 03:24:53
 
 
À
03/07/2014 14:44:15
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
OS:
Windows 8
Network:
Novell 6.x
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01603183
Message ID:
01603227
Vues:
42
>Thanks Viv.
>
>I have my data stored in local storage and now I want to display it. I've been using knockout like this:
>
>
this.runSheetDetails = ko.observableArray(@Html.Raw(Model.RunSheetDetailsJSON));
>
>So I've tried changing that like this:
>
>
this.runSheetDetails = ko.observableArray(JSON.parse(localStorage[this.localKey]));
>
>but then I get binding errors:
>
>Uncaught ReferenceError: Unable to process binding "template: function (){return { name:'list-template',foreach:runSheetDetails} }"
>
>Do you have an example of reading a list of data from localstorage and displaying it?
>
>This is an example of what the json looks like when it comes out of local storage:
>
>[[{"airWayBill":{"customer":{"cus_PK":"5df642b5-7889-419b-8a16-a63196f79571","cus_lastname":"Bachan","cus_firstname":"Kathy-Ann","cus_company":"Kath-Ann Bachan","cus_addr1":"23 Alexandra Street","cus_addr2":"C/O British Academy","cus_number":"6695 "},"awb_pk":"b9311877-eaf1-49b3-bfaf-2e8afedce389","awb_pieces":1,"awb_cusfk":"5df642b5-7889-419b-8a16-a63196f79571","awb_number":"99800640310"},"deliveryHistories":[],"runSheetHeader":null,"rnd_pk":"7c8d9f45-813b-4120-945d-91e4cfbaedba","rnd_rnhfk":"548a5288-c65d-43ac-be7c-fec662fc154a","rnd_awbfk":"b9311877-eaf1-49b3-bfaf-2e8afedce389"},{"airWayBill":{"customer":{"cus_PK":"4b0a83af-ef75-4567-b564-d4288ed193a0","cus_lastname":"Ambrose","cus_firstname":"Leonardo","cus_company":"Leonardo Ambrose","cus_addr1":"11 Braemar Rd,","cus_addr2":null,"cus_number":"1463 "},"awb_pk":"bea8497f-b956-4a4a-9702-c5eddcf014c7","awb_pieces":1,"awb_cusfk":"4b0a83af-ef75-4567-b564-d4288ed193a0","awb_number":"99802580636"},"deliveryHistories":[],"runSheetHeader":null,"rnd_pk":"39d225f2-b064-45fa-8034-7d6a92aa7b4e","rnd_rnhfk":"548a5288-c65d-43ac-be7c-fec662fc154a","rnd_awbfk":"bea8497f-b956-4a4a-9702-c5eddcf014c7"}"]
>
>(note I deleted a lot of the data so may not ave terminated the json properly)

What code did you use to put the above *into* localStorage. Can you compare the output from the MVC Html.Raw() with the above object ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform