Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Datatables Columns


Hello,

I would like to ask on how can I be able to add the "Actions" Column in javascript or is there other way to do it.
I want to retain the styling from your sample pages. https://preview.keenthemes.com/metronic8/demo1/apps/customers/list.html

datatable = $(table).DataTable({
"ajax": {
url: "/Image/GetImageList",
type: "POST",
datatype: "json",
dataSrc: function (data) {
return data.value;
}
},
"columns": [
{ "data": "value" },
],
"info": false,
'order': [],
'columnDefs': [
{ orderable: false, targets: 0 }, // Disable ordering on column 0 (checkbox)
]
});


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Hi Angela Ambas, ​ Sure, we will try to help you out as much as possible. ​ ​ The KTMenu for the actions link is populated in HTML.

​if you like to dynamically populate the KTMenu you should copy the KTMenu HTML code from the HTML template and set it via JS code for the required column:

​const  KTMenuMarkup = `

    Actions 





`;
 { "data": KTMenuMarkup }     
​
// Re-init functions on every table re-draw -- more info: https://datatables.net/reference/event/draw
datatable.on('draw', function () {
    KTMenu.init(); // reinit KTMenu instances once they populated dynamically
});

​ Also make sure that "/Image/GetImageList", returns proper JSON format as per datatables.net docs. You should debug your server-side code as well.

Regards.

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(