Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaAlRashed authored Nov 11, 2024
1 parent 326505f commit d6adf4f
Showing 1 changed file with 12 additions and 46 deletions.
58 changes: 12 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,20 @@ public class Product

[CellEditor("agLargeTextCellEditor")]
public string? Description { get; set; }

[HeaderName("Category")]
public int CatId { get; set; }

[Required(true)]
[HeaderName("Image")]
public FileInput? Image { get; set; }
}

public class FileInput : IFileInput
{
public IFormFile? File { get; set; }
public string? Name { get; set; }
public string? Path { get; set; }
}
```

### Example Razor View

- Download the required js/css files from here:
[Gridazor.zip](https://github.com/user-attachments/files/17090694/Gridazor.zip)

- Import them in Layout.cshtml:
- Import ag-grid library:
```csharp
<link rel="stylesheet" href="~/lib/Gridazor/GridazorDropdown/GridazorDropdown.css" />
<link rel="stylesheet" href="~/lib/Gridazor/GridazorFileInput/GridazorFileInput.css" />

<script src="https://cdn.jsdelivr.net/npm/ag-grid-community/dist/ag-grid-community.min.js"></script>
<script src="~/lib/Gridazor/GridazorDropdown/GridazorDropdown.js"></script>
<script src="~/lib/Gridazor/GridazorFileInput/GridazorFileInput.js"></script>
<script src="~/lib/Gridazor/Gridazor.js"></script>
```

And Gridazor client-side:
```csharp
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridazor@latest/dist/gridazor.css" />
<script src="https://cdn.jsdelivr.net/npm/gridazor@latest/dist/gridazor.js"></script>
```

```csharp
Expand All @@ -91,6 +74,7 @@ public class FileInput : IFileInput
}))
{
<div class="card-header">
<button id="add-button" type="button" class="btn btn-primary">Add</button>
<button id="delete-button" type="button" class="btn btn-danger">Delete</button>
</div>
<div class="card-body">
Expand All @@ -107,30 +91,12 @@ public class FileInput : IFileInput
```js
@section Scripts{
<script>
const dropdownValues = @Html.Raw(Json.Serialize(ViewBag.Cats));
$("#myGrid").gridazor({
const gridazor = new Gridazor(gridElement, {
propertyName: '@nameof(Model.Products)',
overrideColumnDefs: [
{
field: "catId",
cellEditor: GridazorDropdown,
cellEditorParams: {
values: dropdownValues.map(item => ({
value: item.id,
text: item.name
}))
},
valueFormatter: (params) => gridazorDropdownHelper.valueFormatter(params)
},
{
field: "image",
cellEditor: GridazorFileInput,
cellRenderer: (params) => gridazorFileInputHelper.cellRender(params)
}
],
enableDelete: true,
deleteButtonId: "delete-button"
});
deleteButtonId: "delete-button",
addByButton: true,
addButtonId: "add-button"
</script>
}
```
Expand Down

0 comments on commit d6adf4f

Please sign in to comment.