-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #752 from riganti/fix/gridview-inline-editing
Allow rename of a IRowEditOptions.PrimaryKeyPropertyName property through JsonProperty
- Loading branch information
Showing
6 changed files
with
139 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/DotVVM.Samples.Common/ViewModels/ControlSamples/GridView/RenamedPrimaryKeyViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DotVVM.Framework.Controls; | ||
using Newtonsoft.Json; | ||
|
||
namespace DotVVM.Samples.BasicSamples.ViewModels.ControlSamples.GridView | ||
{ | ||
public class RenamedPrimaryKeyViewModel | ||
{ | ||
public GridViewDataSet<SampleDto> Samples { get; set; } = new GridViewDataSet<SampleDto> { | ||
RowEditOptions = new RowEditOptions { | ||
PrimaryKeyPropertyName = nameof(SampleDto.Id) | ||
}, | ||
Items = { | ||
new SampleDto | ||
{ | ||
Id = "1", | ||
Name = "One" | ||
}, | ||
new SampleDto | ||
{ | ||
Id = "2", | ||
Name = "Two" | ||
}, | ||
new SampleDto | ||
{ | ||
Id = "3", | ||
Name = "Three" | ||
} | ||
} | ||
}; | ||
|
||
public void Edit(string id) | ||
{ | ||
Samples.RowEditOptions.EditRowId = id; | ||
} | ||
|
||
public void Save() | ||
{ | ||
Samples.RowEditOptions.EditRowId = null; | ||
} | ||
|
||
public class SampleDto | ||
{ | ||
[JsonProperty("id", Required = Required.Default, NullValueHandling = NullValueHandling.Ignore)] | ||
public string Id { get; set; } | ||
|
||
public string Name { get; set; } | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/DotVVM.Samples.Common/Views/ControlSamples/GridView/RenamedPrimaryKey.dothtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@viewModel DotVVM.Samples.BasicSamples.ViewModels.ControlSamples.GridView.RenamedPrimaryKeyViewModel | ||
|
||
<!DOCTYPE HTML> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
<dot:GridView DataSource="{value: Samples}" | ||
InlineEditing="true" | ||
data-ui="gridview"> | ||
<dot:GridViewTextColumn ValueBinding="{value: Name}" HeaderText="Name" /> | ||
<dot:GridViewTemplateColumn> | ||
<ContentTemplate> | ||
<dot:LinkButton Click="{command: _root.Edit(Id)}" | ||
data-ui="edit-button"> | ||
<span>Edit</span> | ||
</dot:LinkButton> | ||
</ContentTemplate> | ||
<EditTemplate> | ||
<dot:LinkButton Click="{command: _root.Save()}" | ||
data-ui="save-button"> | ||
<span>Save</span> | ||
</dot:LinkButton> | ||
</EditTemplate> | ||
</dot:GridViewTemplateColumn> | ||
</dot:GridView> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.