0
我目前正在爲客戶請求修改樹視圖控件(Telerik MVC Extensions)。他們的要求很簡單:如果樹中的項目具有附件,請在節點旁邊添加回形針以識別它。將圖像添加到樹視圖中的僅一個節點
我到目前爲止一直能夠做到這一點,但發現了一個這樣的小呃。我可以將圖像添加到具有附件的特定節點,但是,所有不應該沒有圖像的節點(因此,我的意思是它們應該在樹內顯得正常)。相反,我發現樹在回形針圖像的大小上留下了空白。
有沒有辦法動態關閉這個空白(如果沒有必要,也可以不添加圖片網址)?以下是我執行此過程的代碼(由於僅底層顯示附件,因此在樹的展開方法上完成)。
導航控制器
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GetNextTreeViewLevel(TreeViewItem node)
{
...
//If bottom layer, then execute the following
var data = _TreeRepo.GetProcessesByParcel(int.Parse(values[1]), cntTreeList);
nodes = from item in data
select new TreeViewItem
{
Text = item.strProcess,
Value = "PR" + "," + item.cntProcess.ToString(),
LoadOnDemand = false,
Enabled = true,
Selected = SelectedSearchResult.ToString().Length > 0
&& SelectedSearchResult.ToString().Split('~').Length > 3
&& decimal.Parse(SelectedSearchResult.ToString()
.Split('~')
.Last()
.Substring(2)) == item.cntProcess
ImageUrl = item.ysnHasAttachment.HasValue && item.ysnHasAttachment.Value == 1
? @"/Content/NewImages/attachment.png"
: string.Empty
};
return new JsonResult { Data = nodes };
}
的是什麼樣子無/有碼圖像URL屏幕截圖: