ag-grid / ag-grid-aurelia

Aurelia wrapper for ag-Grid project
MIT License
23 stars 8 forks source link

defaultColDef doesn't work when columns defined in html #24

Open ShaunVanDyk opened 6 years ago

ShaunVanDyk commented 6 years ago

I'm submitting a ... (check one with "x")

[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/ceolter/ag-grid-aurelia/blob/master/CONTRIBUTING.md#question

Current behavior defaultColDef on GridOptions doesn't apply when defining columns in html templates using ag-grid-column. If columns are defined in typescript / js on the GridOptions, then the defaults get applied fine.

Expected behavior defaultColDef on the grid options should apply the properties to the columns if the columns themselves don't define that option. For example, if defaultColDef.editable = false, and the column doesn't define the property, then it should be false. If a column sets editable = true, then only that column will be editable, the rest will be readonly.

Minimal reproduction of the problem with instructions Doesn't work:

<!-- html -->
<ag-grid-aurelia class="ag-theme-bootstrap" grid-options.bind="defaultGridOptions"
        row-data.bind="rowData" style="height: 350px;">

        <!-- This column should be editable, as it defines the property so should override the default -->
        <ag-grid-column header-name="Code" field="code" width.bind="95" editable.bind="true">
        </ag-grid-column>

        <!-- Shouldn't be editable, doesn't define editable so should pick up the default -->
        <ag-grid-column header-name="Description" field="description" width.bind="150">
        </ag-grid-column>
</ag-grid-aurelia>
<!-- ts -->
private defaultGridOptions: GridOptions = <GridOptions>{
        defaultColDef: {
            editable: true
        }
    };
private rowData = [
    { code: "a", description: "apple" },
    { code: "b", description: "banana" }
];

Works:

<!-- html -->
<ag-grid-aurelia class="ag-theme-bootstrap" grid-options.bind="defaultGridOptions"
        row-data.bind="rowData" style="height: 350px;">
</ag-grid-aurelia>
<!-- ts -->
private defaultGridOptions: GridOptions = <GridOptions>{
        defaultColDef: {
            editable: true
        },
        colDefs: [
            { headerName: "Code", field: "code", editable: true },
            { headerName: "Description", field: "description" }
        ]
    };

private rowData = [
    { code: "a", description: "apple" },
    { code: "b", description: "banana" }
];

Please tell us about your environment: Windows 10, VSCode, npm, aurelia-cli

ShaunVanDyk commented 6 years ago

Adding a "Type" also doesn't work via templating, but it does when defining in the code behind. The pull request fixes that as well.