Author Topic: linking to url in a cell  (Read 7814 times)

precator

  • Newbie
  • *
  • Posts: 4
    • View Profile
linking to url in a cell
« on: October 29, 2013, 05:09:26 am »
Is there any way to link to a url from say an id column? like instead of just having the number I would like it linkable to say a details page and pass the id in..

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: linking to url in a cell
« Reply #1 on: October 29, 2013, 11:58:48 am »

precator

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: linking to url in a cell
« Reply #2 on: October 29, 2013, 10:14:24 pm »
Can you provide an example where I just prepend text and append at the end?

like I want to create a url link from the id field. I see there is a render function but no example on how to do that..

I see there is this >> function( ui ){};   << but not sure what to do with that..

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: linking to url in a cell
« Reply #3 on: October 29, 2013, 11:25:52 pm »
There is an example on how to use render callback:

http://paramquery.com/demos/render_cells

precator

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: linking to url in a cell
« Reply #4 on: October 30, 2013, 07:19:40 pm »
whenever I try to access an index or rowData I get an undefined.. Attaching the code.. Any idea what is wrong? I put the render function in the colModel.

var colM = [
            {
                title: "OrderID", dataIndx: "OrderID", width: 100, render: function (ui) {
                    var rowData = ui.rowData;
                    return "textbefore" + rowData[1] + "textafter" ;
                }
            },
            { title: "CustomerName", dataIndx: "CustomerName", width: 130 },
            { title: "UnitPrice", dataIndx: "UnitPrice", width: 100, align: "right",dataType: "float" },
            { title: "OrderDate", dataIndx: "OrderDate", width: 100 }
        ];

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: linking to url in a cell
« Reply #5 on: October 30, 2013, 10:34:46 pm »
your dataIndx are strings, so I assume that you are using JSON data.

your render callback would be

render: function (ui) {
                    var rowData = ui.rowData;
                    return "textbefore" + rowData["OrderID"] + "textafter" ;
                }




stebe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: linking to url in a cell
« Reply #6 on: October 31, 2013, 07:59:13 pm »
Perhaps this is what you are looking for:

Code: [Select]
var colModel = [
    { title: "Employee name", width: 200, dataType: "string", dataIndx: "EmployeeName" },
    { title: "Hired on", width: 150, dataType: "string", dataIndx: "DateTimeHired", render: function (ui) {
        var cellData = ui.rowData[this.dataIndx];

        if (cellData) {
            // Convert JSON DateTime e.g. /Date(2176326711)/ to yyyy-mm-dd format
            return deserializeJSONDateTime(cellData);
        }
    }
];
« Last Edit: October 31, 2013, 08:30:13 pm by stebe »