radzen数据网格动态数据和值

发布于 2025-01-21 14:37:41 字数 1941 浏览 2 评论 0原文

我需要能够从动态数据中生成列和值。我的模型是包含字符串和另一个列表的列表。字符串是列名,我可以正确显示。但是,我无法正常工作。我一直都在得到三件事之一。 1)无值2)控件名称3)每个列级项目的值,但值。

因此,使用3列,每列具有3个数据点,我可以生成所有三列,但是我在每列中获得所有三列数据的价值。

以下是我用于数据网格的代码,以及将数据添加到外部和内部列表中的代码。

如果有人对如何完成此操作有任何想法,我现在可以真正使用帮助。

  public List<rdzTest> getData()
    {
        for(int i = 0; i<5; i++)
        {
            rdzTest rt = new rdzTest();
            //rt.name = new List<string>();
            rt.name = "Property Name " + " -- " + i.ToString();
            rt.values = new List<string>();
            string s = "";// "<ul>";
            for (int j = 0; j < 10; j++)
            {
                //s += "<li>values " + j.ToString() + " Property -- " + i.ToString() + "</li>";    
                s = "values " + j.ToString() + " Property -- " + i.ToString();   
                rt.values.Add(s);            
            }
            //s += "</ul>";
            //rt.values = s;
            alpha.Add(rt);
            //alpha.name = rt.name;
            //alpha.values = rt.values;
        }
        return alpha;
    }
<RadzenDataGrid TItem="rdzTest" Col Data=@alpha>
    <Columns>        
        @foreach(rdzTest rt in alpha)
        {
            <RadzenDataGridColumn TItem="rdzTest" [email protected] Title="@rt.name">
                <Template>
                    <ul>
                        @foreach(string st in rt.values)
                        {
                            <li>
                                @st
                            </li>
                        }
                    </ul>
                </Template>
            </RadzenDataGridColumn>
        }
    </Columns>
</RadzenDataGrid>

I am needing to be able to generate columns and values from dynamic data. My model is a List that contains a string and another list. The string is the column name, which I can get to display correctly. The list however I have not been able to get working correctly. I am getting one of three things all the time. 1) No values 2) The control name 3) The values but the values for each Column level item.

So with 3 columns and each column having 3 data point I can generate all three columns, but I get all three columns worth of data in each column.

Below is the code I am using for the data grid it's self as well as the code for adding the data to the outer and inner lists.

If anyone has any ideas of how to complete this I could really use the help at this point.

  public List<rdzTest> getData()
    {
        for(int i = 0; i<5; i++)
        {
            rdzTest rt = new rdzTest();
            //rt.name = new List<string>();
            rt.name = "Property Name " + " -- " + i.ToString();
            rt.values = new List<string>();
            string s = "";// "<ul>";
            for (int j = 0; j < 10; j++)
            {
                //s += "<li>values " + j.ToString() + " Property -- " + i.ToString() + "</li>";    
                s = "values " + j.ToString() + " Property -- " + i.ToString();   
                rt.values.Add(s);            
            }
            //s += "</ul>";
            //rt.values = s;
            alpha.Add(rt);
            //alpha.name = rt.name;
            //alpha.values = rt.values;
        }
        return alpha;
    }
<RadzenDataGrid TItem="rdzTest" Col Data=@alpha>
    <Columns>        
        @foreach(rdzTest rt in alpha)
        {
            <RadzenDataGridColumn TItem="rdzTest" [email protected] Title="@rt.name">
                <Template>
                    <ul>
                        @foreach(string st in rt.values)
                        {
                            <li>
                                @st
                            </li>
                        }
                    </ul>
                </Template>
            </RadzenDataGridColumn>
        }
    </Columns>
</RadzenDataGrid>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文