Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
Column templates with auto generated columns
posted

I am using igGrid with a JSON datasource that can contain different sets of columns which results in me using auto generated columns. I wish to apply column templates to these columns and want to know if this is possible. I can build a column template on the server where I know which columns will be used to populate the grid and pass it over to the client, but how do I apply that template to the grid when binding the data?

I am also interested in other customizations such as changing the Display Name, Column Width, Column Order etc of each column, can this be set through the column template?

Data binding on client:

$("#dataGrid").igGrid({
        autoGenerateColumns: true,
        defaultColumnWidth: "150px",
        width: "100%",
        dataSource: data,
        dataSourceType : "json",
        responseDataKey: "data"});

Parents
  • 2355
    Verified Answer
    Offline posted

    Hi Elin,

    Thank you for posting in our forums!

    Yes, you can set column template to auto generated column. The grid has just the right API method for this purpose – setColumnTemplate. The method accepts the column key and the template as arguments. Since you don’t define column keys you have to get them from the generated “columns” collection. I prepared a sample page that demonstrates my solution. Please review it and let me know if this works for you.

    I’m looking forward to your reply!

    Kind regards,
    Petko Zhekov
    Software Engineer

    sample-template-agc.zip
Reply Children