How to insert a non - database field in table.

How to insert a non - database field in table.

realdreamerrealdreamer Posts: 6Questions: 0Answers: 0
edited November 2012 in DataTables 1.9
Hi,
I have table with 3 ths. [code] Username Password Avatar(User's Image)[/code].
I am using the PHP Server side scripting. I also wanna display the images in the table.

If I pass the empty space for the images field, its not processing at all.
[code]$aColumns = array( 'username', 'password', ' ');[/code]

How to display the user's images within the table td.


Please help me to solve this issue.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'd suggest using mData and mRender:

    [code]
    mData: 'id', // id column - string here, could be an integer if you are using plain arrays
    mRender: function (d, type, row) {
    return ''; // d is the id
    }
    [/code]

    Allan
  • realdreamerrealdreamer Posts: 6Questions: 0Answers: 0
    edited November 2012
    Can you send any LIVE EXAMPLE CODE or LINK?
  • realdreamerrealdreamer Posts: 6Questions: 0Answers: 0
    edited November 2012
    Hi, I have referred the mData and mRender function which you are suggested. I have tried to create the same example as they are mentioned.

    I have stored the four values in mysql table. id(Auto Increment), username, password, profile.

    But in my php i am reading the 3values,

    [code] $aColumns = array( 'username', 'password', 'profile'); [/code]

    I want to pass the profile value into anchor tag. The code is below

    [code]
    $('#example').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "scripts/server_processing.php",
    "aoColumnDefs": [ {
    "aTargets": [ 2 ],
    "mData": "profile",
    "mRender": function ( data, type, full ) {
    return 'Profile';
    }
    } ],
    })
    [/code]

    But, when I try to pass the values into anchor tag. I am getting the 0(null) values in that anchor tag.

    If I display directly, the profile link values are passing perfectly.


    So, please kindly help me to solve this issue.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited November 2012
    What is the server returning? If it is arrays then `mData: profile` isn't going to match anything. `mData: 2` would probably be what you want.

    Allan
  • realdreamerrealdreamer Posts: 6Questions: 0Answers: 0
    Thank a ton man :).. Its working perfectly.

    In case if i have to display the images static (without fetching it from database), but the different images I want to display..

    How to do this?

    Please kindly help me on this..
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I don't understand the question. You want to put `img` tags in the HTML? You've put an `a` tag in using the above method, can't you just use the same for images?
  • realdreamerrealdreamer Posts: 6Questions: 0Answers: 0
    Hi, Sorry..

    If i change the img tag that's working fine.

    In the above table, I am retrieving the values from database.

    But, my doubt is

    If I change the code as below
    [code]
    $('#example').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "scripts/server_processing.php",
    "aoColumnDefs": [ {
    "aTargets": [ 2 ],
    "mData": "profile",
    "mRender": function ( data, type, full ) {
    return '';
    }
    } ],
    })
    [/code]

    then it displays the same image in every row. But, I want to display different images without using database.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    A different image based on what? In the above `a` example you've got the link being different based on the id from the database. Can't you just use the same for images?
  • realdreamerrealdreamer Posts: 6Questions: 0Answers: 0
    Hi, Please read my post fully.

    I have mentioned that. "I want to display different images(static) without using database".
  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    This is a very valid question :)
    [quote]allan said: A different image based on what? [/quote]

    You can certainly load images from local folder / directory.

    You can have an array built within the script, assign id's for each profile and match the image name /id with the profile name / id and load that into the table. Frankly speaking, this is what happens when you use database.
This discussion has been closed.