2017年6月29日 星期四

[jQuery] refresh jsTree(3.2.1) 搭配ASP.NET MVC與json

說明:
使用jQuery plugin jsTree可在網頁上呈現樹狀結構資料,若需要refresh或reload資料,該如何做?


做法:

新增jsTree的物件Model。資料來源使用json文字檔,來簡單模擬資料變更。


在Controller加入取得Tree Nodes的Action Method,
其中使用HostingEnvironment.MapPath取代Server.MapPath,
因Server.MapPath在HttpContext類別下,需有request才可使用。

在View建立jsTree的instance與refreshTree function,新增一button做重新整理。














參考資料:
http://www.dotnetqueries.com/Article/62/implementing-jstree-in-asp-net-mvc-with-json-data
https://www.jstree.com/api/#/?q=.jstree Event
https://www.jstree.com/api/#/?q=(
https://msdn.microsoft.com/zh-tw/library/system.web.httpcontext(v=vs.110).aspx

2017年6月25日 星期日

[EF] 使用Entity Framework code first紀錄

● VS 2013與EF6預設沒有code first精靈,該如何解決?
Ans: 安裝Entity Framework 6 Tools for Visual Studio 2012 & 2013

● 不透過精靈,使用code first建立新的資料庫?
to be continued...