Skip to content

Commit 4e4f950

Browse files
committed
GridView should pass the GridViewDataSet, not the List to it's knockout binding (fix)
1 parent cfb8e24 commit 4e4f950

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/Framework/Framework/Controls/GridView.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,9 @@ protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequest
536536
var mapping = userColumnMappingService.GetMapping(itemType!);
537537
var mappingJson = JsonConvert.SerializeObject(mapping);
538538

539-
var dataBinding = TryGetKnockoutForeachingExpression(unwrapped: true).NotNull("GridView does not support DataSource={resource: ...} at this moment.");
539+
var dataBinding =
540+
(GetDataSourceBinding() as IValueBinding ?? throw new DotvvmControlException(this, "GridView does not support DataSource={resource: ...} at this moment."))
541+
.GetKnockoutBindingExpression(this, unwrapped: true);
540542
writer.AddKnockoutDataBind("dotvvm-gridviewdataset", $"{{'mapping':{mappingJson},'dataSet':{dataBinding}}}");
541543
base.AddAttributesToRender(writer, context);
542544
}

src/Tests/ControlTests/ResourceDataContextTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ public async Task Repeater()
9595
<span class=name data-id={resource: Id}>{{resource: Name}}</span>
9696
9797
<span>{{value: _parent.CommandData}}</span>
98-
99-
<dot:Button Click={command: _root.TestMethod(Name)} />
10098
</dot:Repeater>
10199
"
102100
);

src/Tests/ControlTests/testoutputs/ResourceDataContextTests.Repeater.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
<div>
1616
<span class="name" data-id="1">One</span>
1717
<span data-bind="text: CommandData"></span>
18-
<input onclick="dotvvm.postBack(this,[&quot;Customers/[0]&quot;],&quot;VoomVIgRFCWNqBr4&quot;,&quot;&quot;,null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;" type="button" value="">
1918
-------------------
2019
<span class="name" data-id="2">Two</span>
2120
<span data-bind="text: CommandData"></span>
22-
<input onclick="dotvvm.postBack(this,[&quot;Customers/[1]&quot;],&quot;VoomVIgRFCWNqBr4&quot;,&quot;&quot;,null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;" type="button" value="">
2321
</div>
2422
</body>
2523
</html>

0 commit comments

Comments
 (0)