Tuesday 8 December 2015

Slick Grid Link Formater

You can add URL links in slick grid report
Code:

example:
  {id: "sample_id", name: "Sample Id", field: "sampleid", minWidth:120,
   formatter: linkFormatter = function ( row, cell, value, columnDef, dataContext ) {
                            return '<a href="desk#Form/Sample Entry Register/' + dataContext['sampleid'] + '">' + value + '</a>';
    }

   }

full example:

columns.push(
                {id: "id", name: "Sr.No", field: "id", minWidth:5},
                {id: "sample_id", name: "Sample Id", field: "sampleid", minWidth:120,
                    formatter: linkFormatter = function ( row, cell, value, columnDef, dataContext ) {
                            return '<a href="desk#Form/Sample Entry Register/' + dataContext['sampleid'] + '">' + value + '</a>';
                        }},
                {id: "customer", name: "Customer", field: "customer",minWidth:200,
                      formatter: linkFormatter = function ( row, cell, value, columnDef, dataContext ) {
                                return '<a href="desk#Form/Customer/' + dataContext['customer'] + '">' + value + '</a>';
                            }},
                {id: "type", name: "Type", field: "type",minWidth:120},
                {id: "priority", name: "Priority", field: "priority",minWidth:120},
                {id: "standard", name: "Standard", field: "standard",minWidth:120}
                   );

5 comments:

  1. how this will create hyperlink, since I am new to slickgrid , trying to explore its creature, I think it will create hyperlink to all the row values, which if I want hyperlink on single row single column entity?

    ReplyDelete
  2. This will create hyper-link of all row single column.
    If you want to hyper-link single cell you need to write your own formatter function that will format only your cell.

    Please refer this post
    http://sbkolate.blogspot.in/2015/08/ability-to-color-cells-based-on-cell.html

    Let me know if you need any help

    ReplyDelete
  3. yeah it worked..thanks much..:)

    ReplyDelete