C#:GridPanel每行带有URL以下载文件

时间:2018-08-22 13:35:31

标签: c# ext.net

这是我在代码后面的网格:

GridPanel grid = new GridPanel
{
    Height = 200,
    EnableColumnHide = false,
    EmptyText = "No Documents",
    Store =
    {
        new Store
        {
            Model = 
            {
                new Model 
                {
                    Fields = { new ModelField("Name") }
                }
            },
            DataSource = data
        }
    },
    ColumnModel =
    {
        Columns =
        {
            new Column { ID = "clmDoc", Text = "Documents Exported", DataIndex = "Name", Width = 400  }
        }
    }
};

我如何在每一行中显示文件的URL,以便用户可以下载文件?文件存储在~/Files/Export/Documents/file1.pdf

1 个答案:

答案 0 :(得分:0)

像这样声明您的专栏:

new Column()
        {                    
            Text = "MyColumn",
            DataIndex = "UrlField",
            Width = 200,
            Renderer = new Renderer("function (value, metadata, record) { return '<a href=\"http://www.mylink.com\" target=top >'+value+'<a/>'} ")

        }