How to add more property to a column when make search with ajax?

How to add more property to a column when make search with ajax?

hungdang996hungdang996 Posts: 3Questions: 2Answers: 0

I'm having a datatable with server-side mode and individual column search. Each time the input on keyup, i will call ajax to get filter, the simple request of data to server like this:

{
    "draw": "1",
    "columns[0][data]": "responsive_id",
    "columns[0][name]": "",
    "columns[0][searchable]": "true",
    "columns[0][orderable]": "false",
    "columns[0][search][value]": "",
    "columns[0][search][regex]": "false",
    "columns[1][data]": "id",
    "columns[1][name]": "",
    "columns[1][searchable]": "false",
    "columns[1][orderable]": "false",
    "columns[1][search][value]": "",
    "columns[1][search][regex]": "false",
    "columns[2][data]": "id",
    "columns[2][name]": "",
    "columns[2][searchable]": "false",
    "columns[2][orderable]": "true",
    "columns[2][search][value]": "",
    "columns[2][search][regex]": "false",
    "columns[3][data]": "username",
    "columns[3][name]": "username",
    "columns[3][searchable]": "true",
    "columns[3][orderable]": "true",
    "columns[3][search][value]": "",
    "columns[3][search][regex]": "false",
    "columns[4][data]": "fullname",
    "columns[4][name]": "fullname",
    "columns[4][searchable]": "true",
    "columns[4][orderable]": "true",
    "columns[4][search][value]": "",
    "columns[4][search][regex]": "false",
    "columns[5][data]": "email",
    "columns[5][name]": "email",
    "columns[5][searchable]": "true",
    "columns[5][orderable]": "true",
    "columns[5][search][value]": "",
    "columns[5][search][regex]": "false",
    "columns[6][name]": "act_col",
    "columns[6][searchable]": "true",
    "columns[6][orderable]": "false",
    "columns[6][search][value]": "",
    "columns[6][search][regex]": "false",
    "order[0][column]": "2",
    "order[0][dir]": "desc",
    "start": "0",
    "length": "10",
    "search[value]": "",
    "search[regex]": "false"
}

and i want to do with each of columns[i], i can append 2 properties such as alias and col to handle something for pre-sql, but idk how to make it, maybe when input filter on key up i will get some specific attribute value to assign it to 2 new properties of searching column.

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    I'm not clear what you're after, but you can use ajax.data to add to the data being sent to the server,

    Colin

Sign In or Register to comment.