How can I change the delimiter (comma) to semicolon for array type of data on a column.

How can I change the delimiter (comma) to semicolon for array type of data on a column.

gouravrathour007gouravrathour007 Posts: 9Questions: 2Answers: 0
edited December 2021 in General

Hi Team,

How can I change the delimiter (comma) to semicolon for array type of data on a column?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948

    Please provide more details about the problem you are trying to solve.

    Kevin

  • gouravrathour007gouravrathour007 Posts: 9Questions: 2Answers: 0


    A big thanks for your response.

    Please refer attached screenshot as the screenshot, the library automatically changes the array type of data into a comma-separated string I want to replace the comma with a semicolon.

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948

    Thanks for clarifying. You can use columns.render to manipulate the displayed data. See the data rendering docs and this example for more details.

    Kevin

  • gouravrathour007gouravrathour007 Posts: 9Questions: 2Answers: 0
    edited December 2021

    Thanks for the quick response!!

    Can we do it globally not only for a specific column?

    if the data type is an array just join the string with semicolons.

    same as the grid is doing with comma.

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948
    edited December 2021 Answer ✓

    You can use columnDefs and define columnDefs.targets for the columns.render function. You can define an array of columns or use _all for all columns. However you can define only one columns.render function per column.

    Or you can have the server return a string with semicolon separated values instead of an array.

    Kevin

  • gouravrathour007gouravrathour007 Posts: 9Questions: 2Answers: 0

    I found a solution finally, Thanks for your support.

  • Fuad_coxFuad_cox Posts: 1Questions: 0Answers: 0

    can you tell me what you got the final solution?

  • gouravrathour007gouravrathour007 Posts: 9Questions: 2Answers: 0

    {
    targets: "_all",
    render: (data, type, row, meta) => {
    let value: any = "";
    if (typeof data == "boolean") {
    value = data ? "Yes" : "No";
    } else value = data || "";
    return "<span class='dtData'>" + value + "</span>";
    }
    }

Sign In or Register to comment.