Skip to content

Commit

Permalink
hierarchy repeater: fix client-side command in markup control
Browse files Browse the repository at this point in the history
problem was that that BindingHelper.FindDataContextTarget
assumed there was one more data context layer since we used set
data context type and DataContext on different controls.
Because of that command client-side and server-side
data context paths didn't match.
Technically, this is a glitch of BindingHelper, not HierarchyRepeater,
but "fixing" BindingHelper will break many things and it's hopefully
going to be done in #1392
  • Loading branch information
exyi committed Dec 7, 2022
1 parent f7ed8f7 commit b6052cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Framework/Framework/Controls/HierarchyRepeater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ private DotvvmControl CreateServerItem(
Internal.PathFragmentProperty,
$"{GetPathFragmentExpression()}{parentSegment}/[{index}]");
placeholder.SetValue(Internal.UniqueIDProperty, "item");
placeholder.SetDataContextTypeFromDataSource(GetDataSourceBinding()); // DataContext type has to be duplicated on the placeholder, because BindingHelper.FindDataContextTarget (in v4.1)
dataItem.Children.Add(placeholder);
ItemTemplate.BuildContent(context, placeholder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

<div><!-- ko dotvvm-SSR-foreach: { data: HItems } --><!-- ko dotvvm-SSR-item: 0 -->
<!-- ko with: $rawData --><div>
<input type=button value=A onclick='dotvvm.postBack(this,["HItems/[0]","$parents[1]"],"RR93KduwUKJIXxFp","c7_0L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<input type=button value=A onclick='dotvvm.postBack(this,["HItems/[0]","$parent"],"RR93KduwUKJIXxFp","c7_0L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<!-- /ko --><!-- ko dotvvm-SSR-foreach: { data: ko.unwrap($foreachCollectionSymbol)[0]().Children } --><!-- ko dotvvm-SSR-item: 0 -->
<!-- ko with: $rawData --><div>
<input type=button value=A_1 onclick='dotvvm.postBack(this,["HItems/[0]/[0]","$parents[1]"],"RR93KduwUKJIXxFp","c7_0_0L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<input type=button value=A_1 onclick='dotvvm.postBack(this,["HItems/[0]/[0]","$parent"],"RR93KduwUKJIXxFp","c7_0_0L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<!-- /ko --><!-- ko dotvvm-SSR-foreach: { data: ko.unwrap($foreachCollectionSymbol)[0]().Children } --><!-- ko dotvvm-SSR-item: 0 -->
<!-- ko with: $rawData --><div>
<input type=button value=A_1_1 onclick='dotvvm.postBack(this,["HItems/[0]/[0]/[0]","$parents[1]"],"RR93KduwUKJIXxFp","c7_0_0_0L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<input type=button value=A_1_1 onclick='dotvvm.postBack(this,["HItems/[0]/[0]/[0]","$parent"],"RR93KduwUKJIXxFp","c7_0_0_0L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<!-- /ko --><!-- ko dotvvm-SSR-item: 1 -->
<!-- ko with: $rawData --><div>
<input type=button value=A_1_2 onclick='dotvvm.postBack(this,["HItems/[0]/[0]/[1]","$parents[1]"],"RR93KduwUKJIXxFp","c7_0_0_1L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<input type=button value=A_1_2 onclick='dotvvm.postBack(this,["HItems/[0]/[0]/[1]","$parent"],"RR93KduwUKJIXxFp","c7_0_0_1L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<!-- /ko --><!-- /ko --><!-- /ko --><!-- ko dotvvm-SSR-item: 1 -->
<!-- ko with: $rawData --><div>
<input type=button value=B onclick='dotvvm.postBack(this,["HItems/[1]","$parents[1]"],"RR93KduwUKJIXxFp","c7_1L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<input type=button value=B onclick='dotvvm.postBack(this,["HItems/[1]","$parent"],"RR93KduwUKJIXxFp","c7_1L_c9",null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;' /></div><!-- /ko -->
<!-- /ko --><!-- /ko --></div>


Expand Down

0 comments on commit b6052cc

Please sign in to comment.