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
170
Iggrid formatting cell values
posted

Hi,

I have comma seperated values in iggrid cell,and need to show the values

one after the other in new line.is there any feature in iggrid to do?

Regards

Raghu

Parents
No Data
Reply
  • 17590
    Offline posted

    Hello Raghu,

    Thank you for posting in our community.

    What I can suggest for achieving your requirement is using  formatter for the column that you would like to style. Formatter is a reference to a function which will be used for formatting cell values. The function should accept a value and return new formatted value. In you scenario you could get reference to the string value of the cell, replace all the commas with new lines and return the newly formatted string. For example:

     $("#grid").igGrid({
                    dataSource: data,
                    columns: [
                      { headerText: "ID", key: "ID", dataType: "number" },
                      { headerText: "Name", key: "Name", dataType: "string" },
                      {
                          headerText: "Values", key: "Values", dataType: "string", formatter: function (val) {

                              var newVal = val.replace(/ *, */g, '<br>');
                              return newVal;
                          }
                      }
                    ]
                });
            });

    I am also attaching a small sample illustrating my suggestion for your reference.

    Please have a look at this sample and let me know if you need any further assistance.

    igGridComaSeparatedValues.zip
Children