// Create the grid $grid = new ag_grid($options);
// Fetch the data from the PHP backend $dataUrl = 'data.php'; $data = json_decode(file_get_contents($dataUrl), true); aggrid php example updated
// Connect to the database $conn = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName); // Create the grid $grid = new ag_grid($options);
// Check for connections errors if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); $data = json_decode(file_get_contents($dataUrl)
// Define the grid columns $columns = [ ['headerName' => 'Name', 'field' => 'name'], ['headerName' => 'Email', 'field' => 'email'], ['headerName' => 'Department', 'field' => 'department'] ];
// Fetch the data $data = []; while ($row = $result->fetch_assoc()) $data[] = $row;
In this example, we'll create a simple AG Grid application that interacts with a PHP database. Our application will display a grid of data, allow users to filter and sort data, and perform server-side filtering and sorting.