Expand description

Rust bindings for the AG Grid JavaScript library.

With this crate, one is able to use the AG Grid datatable library within a Wasm context in Rust.

A simple example demonstrating server-side data fetching using Yew and related dependencies is as follows:

use ag_grid_rs::{
    gridoptions::{DataSourceBuilder, RowModelType},
    ColumnDef, GridOptions, ToJsValue,
use gloo_net::http::Request;
use serde::Deserialize;
use wasm_bindgen::JsCast;
use web_sys::HtmlElement;
use yew::prelude::*;

pub fn about() -> Html {
        |_| {
            // Get the element to which you want to attach the grid
            let grid_div = get_element_by_id("grid-div");

            // Define your columns
            let field_names = vec!["athlete", "age", "country", "year"];
            let cols = field_names
                .map(|name| ColumnDef::new(name).sortable(true))

            // Create your datasource, including a closure that will retunr rows from the
            // server
            let data_source = DataSourceBuilder::new(|params| async move {
                // `params` contains information from AG Grid about which rows to get, how to
                // sort the data, etc
                let data_url = "https://www.ag-grid.com/example-assets/olympic-winners.json";
                let rows = gloo_net::http::Request::get(data_url)

                Ok((rows, None))

            let grid = GridOptions::<JsonData>::new()

            // `grid` now provides a handle to the grid and column APIs
            || ()

    html! {
            <div id="grid-div" class="ag-theme-alpine" style="height: 500px"/>

#[derive(ToJsValue, Deserialize)]
struct JsonData {
    athlete: String,
    age: Option<usize>,
    country: String,
    year: usize,

fn get_element_by_id(id: &str) -> HtmlElement {
        .expect("unable to get window object")
        .expect("unable to get document object")
        .expect("unable to find grid-div")


pub use column::ColumnApi;
pub use column::ColumnDef;
pub use grid::Grid;
pub use grid::GridApi;
pub use gridoptions::GridOptions;


A collection of parameter types passed to callback functions.
Types pertaining to the grid columns.
Access to the ToJsValue trait for converting types into wasm_bindgen::JsValues.
Types pertaining to grid filtering.
Types pertaining to the Grid itself.
Types pertaining to defining and constructing a Grid.
Types pertaining to grid sorting.

Derive Macros

Automatically derive the ToJsValue trait to enable the annotated type to be serialized to a wasm_bindgen::JsValue.