convert list to string

紀錄一下怎麼把字串組轉為string
字串組為List< string> los = new List< string>;

.NET 2.0
String.Join(String.Empty, los.ToArray());
說明網址

到了4.0多了更好用的新方法~
.NET 4.0
String.Join< string>(String.Empty, los);
說明網址


當然,如果你的字串要改以逗點或是分號來串連,那就不要放String.Empty,而是放 "," 或 ":" 嚕

Disable Automatic DataBinding


無論Telerik或Kendo UI的Grid,在頁面render時必定會去讀取要綁在Grid上的資料,也就是執行MVC中的Action method並將資料呈現在UI上,
以Telerik為例(@Html.Telerik().Grid< mydocument>()
.Name("Grid")
.DataBinding(d => d.Ajax().Select("Query", "Home"))
)

以Kendo UI為例@(Html.Kendo().Grid< myDocument>()
.Name("Grid")
.DataSource(dataSource => dataSource.Ajax()
.ServerOperation(false)
.Read(read => read.Action("Query", "Home")))
)


但,如果你期望一開始不做任何DataBinding,只放個白白的Grid,等使用者確實下條件才去後端撈資料,那就要想辦法阻止automatic databinding這件事發生,
Telerik的做法,是利用OnDataBinding的event// 判斷是否第一次載入
var isFirstLoad = true;
function onDataBinding(e) {
// 當第一次載入,不呼叫 Grid Ajax Select,直接 return
if (isFirstLoad) {
e.preventDefault();
return;
}
}

定義Grid Event
.ClientEvents(c => c.OnDataBinding("onDataBinding"))

那Kendo UI呢?
根據官方說法,目前尚未提供可取消DataSource之RequestStart的event
Currently it is not possible to cancel the RequestStart event of the DataSource. 
We will provide such functionality in the future releases. I am sorry for the inconvenience.

既然前端沒有event可阻擋,那只好在後端撈資料時丟個空instance給Grid,一樣能binding不拋錯,希望未來能盡快release這個event,不然還要多跑一次Action method

Getting Started with Kendo UI

首先來個Kendo UI的網址http://docs.kendoui.com/
雖然正式版剛釋出,但網路上能找的資源差不多都在這了

Kendo UI Complete for ASP.NET MVC(以下簡稱Kendo UI)使用方式和Telerik Extensions for ASP.NET MVC(以下簡稱Telerik)一樣,可下載壓縮檔自行解壓取用檔案,也可使用安裝檔直接將檔案裝在特定路徑。
這邊以安裝檔的方式快速截圖,並說明使用方式如下:




安裝完畢請瀏覽至C:\Program Files (x86)\Telerik\Kendo UI for ASP.NET MVC Q2 2012
  • 將js資料夾所有檔案複製到MVC專案的Scripts
  • 將styles資料夾所有檔案複製到MVC專案的Content
  • 加入Binary參考,路徑為wrappers\aspnetmvc\Binaries\Mvc3\Kendo.Mvc.dll
  • 在主版頁面加入下列資訊<link rel="stylesheet" href="@Url.Content("~/Content/kendo.common.min.css")">
    <link rel="stylesheet" href="@Url.Content("~/Content/kendo.default.min.css")">
    <script src="@Url.Content("~/Scripts/kendo.web.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")"></script>
  • web.config與Views\web.config皆加上namespace<add namespace="Kendo.Mvc.UI" />

Done!

Kendo UI誕生

Telerik前陣子放出消息,表示支援Telerik Extensions for ASP.NET MVC只到明年(2013 Q3),
而最大更新差不多就停留在目前的2012 Q2,之後版本多是修正bug和提升performance

取而代之的是這套Kendo UI Complete for ASP.NET MVC,今年7月已推出正式版,
簡單來說就是Kendo UI=CSS 3 + Html 5 + Javascript,以現階段版本還比不上Telerik的完善,開發文件也不盡完全,還不用急著升級
但未來若要朝MVC 4升級,可能要考慮轉用這套(Telerik Extensions for ASP.NET MVC只支援到MVC 3),另外Kendo對REST也提供比較好的支援,以微軟將推出的.Net Framework 4.5來看也是有此趨勢。

其他參考資訊
官方對一些疑慮的釐清
從Telerik升級到Kendo
Kendo UI Complete for ASP.NET MVC