How to add two json fields to the single column in datatable

How to add two json fields to the single column in datatable

pavantejpavantej Posts: 7Questions: 0Answers: 0
edited August 2013 in General
json+datatable

Replies

  • pavantejpavantej Posts: 7Questions: 0Answers: 0
    Hi Allan,
    This is my JSON File

    {
    "id": -1,
    "error": "",
    "fieldErrors": [],
    "data": [],
    "aaData": [
    {
    "price-point-id": "row_1",
    "description": "CRBT_30",
    "price": "25",
    "st-time": "06:00",
    "end-time": "23:59",
    "rate-code": "None",
    "fallback-id": "None"
    }

    ]
    }

    My Table columns are:Description,Price,Time,Rate-Code,Fallback-ID

    Here in the JSON "st-time" and "end-time" fields should be fixed to "Time" column in the table...
    Please try to help to solve my issue.
    Regards,
    Pavantej
  • allanallan Posts: 63,502Questions: 1Answers: 10,471 Site admin
    Use mRender as a function.

    Allan
  • pavantejpavantej Posts: 7Questions: 0Answers: 0
    edited August 2013
    Thankyou Allan,
    It is working ,but json data is not coming,in the datatable iam seeing as "row.st_time+row.end_time" here i was trying to put json data i.e 6:00+23:59 to st-time & end-time in the datatable . Please correct me if i am making any mistake..

    I written code like this:

    $("#tblData").dataTable( {
    "bPaginate": false,
    "bFilter": false,
    "bInfo": false,
    "sAjaxSource": "rules_alerts.json",
    "aoColumns": [
    { "mData": "description" },
    { "mData": "price" },
    { "mData": "rate-code"},
    { "mData": "fallback-id"},
    {
    mData: null,
    mRender: function (data, type, row) {
    return 'row.st_time+row.end_time';
    }
    }

    ]



    & also please give me any suggestion on how to make that link as bootstrap popover

    Thanks in advance,
  • allanallan Posts: 63,502Questions: 1Answers: 10,471 Site admin
    > 'row.st_time+row.end_time';

    That's just a string - so yes, that's what you would get on the output!

    Try:

    [code]
    ''+(row.st_time+row.end_time)+'';
    [/code]

    > & also please give me any suggestion on how to make that link as bootstrap popover

    I'm afraid I don't know Bootstrap well enough. I'd suggest asking general questions on SO.

    Allan
  • pavantejpavantej Posts: 7Questions: 0Answers: 0
    edited August 2013
    Thank you Allan,
    It is working fine.
    But how to make a popover on this link ''+(row.st_time+row.end_time)+'';
    or
    How to make a modal on clicking that link.....
    For more clarity you can see this "http://getbootstrap.com/2.3.2/javascript.html#modals" site and
    Please click on "Launch Demo Model" in 'Live Demo'

    Thanks in advance
This discussion has been closed.