خرید بک لینک

Vote count: 1

I loop through the list of properties using reflection and assign the table cell that value. My header titles for the columns are in the wrong position at the moment though.

How do I sort the dataList properties based on the header list? I would rather do it this way than sort header list based on properties.

dataList type will always be a class with properties.

public void SetTableStrong<T>(List<T> dataList, List<string> header)
{       
    // Define our columns
    Column c = null;
    foreach (var item in header)
    {
        c = table.addTextColumn(item);
        c.horAlignment = Column.HorAlignment.CENTER;
    }

    // Initialize Your Table
    table.initialize();
    table.data.Clear();

    foreach (var item in dataList.Select((value, index) => new { value, index }))
    {
        Datum d = Datum.Body(item.index.ToString());

        foreach (var property in item.value.GetType().GetProperties())
        {
            var value = property.GetValue(item.value, null);

            if (value == null)
                continue;

            d.elements.Add(value.ToString());
        }
        table.data.Add(d);
    }

    // Draw Your Table
    table.startRenderEngine();
}

asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 4 اسفند 1394 ساعت: 8:08

صفحه بندی