Question on Datagrid button


I have added a datagrid button (setDatagridButton) and I need to pass the ID column currently displayed to the linked page. Is there a way to do it with the Grocery CRUD API or it should be implemented in javascript ?


Hello @ywillener,

Not sure what do you mean. Can you please give a more specific example of what you are trying to do? Maybe you are referring to setActionButton - Grocery CRUD - A PHP CRUD Generator Library ?


Hello @johnny

I’m refering to setDatagridButton - Grocery CRUD - A PHP CRUD Generator Library

I have a table that show a small vignette on each row plus some other columns. When the user click on the datagrid button, I would like to redirect the user to another page that show a bigger version of all the vignettes of the displayed rows.


Hello @ywillener are you referring to the visible columns? If so then this is stored in the localStorage. In order to take the local storage value you will need to add first the setUniqueId for the CRUD. For example:

// You need to have only ONE unique id per CRUD operation or 
// else your different pages will be confused

If your uniqueId is “customers” then you can get your localStorage like this in JavaScript (I’ve created a function to understand it better):

function getVisibleColumns(storageKey) {
    // Retrieve the stored data from local storage
    let persistedData = localStorage.getItem(storageKey);

    // Check if the stored data exists and is not empty
    if (persistedData) {
        // Parse the retrieved JSON string
        let parsedData = JSON.parse(persistedData);
        // Check if the datagrid property exists and is not empty
        if (parsedData && parsedData.datagrid) {
            // Parse the datagrid property
            let datagridContent = JSON.parse(parsedData.datagrid);
            // Check if the visibleColumns property exists and is not empty
            if (datagridContent && datagridContent.visibleColumns) {
                // Return the visible columns
                return datagridContent.visibleColumns;
    // Return null if any of the checks fail
    return null;

// Example usage
let visibleColumns = getVisibleColumns("persist:customers");