@@ -600,7 +600,7 @@ private void FinishCollectingColumns()
600600 throw new ArgumentException ( "The 'HierarchicalToggle' parameter can only be set on the first column of the grid." ) ;
601601 }
602602
603- // Validate and compute offsets for pinned columns .
603+ // Validate pinned columns and seed their initial sticky offsets .
604604 ValidateAndComputePinnedColumns ( ) ;
605605
606606 // Always re-evaluate after collecting columns when using displaymode grid. A column might be added or hidden and the _internalGridTemplateColumns needs to reflect that.
@@ -624,12 +624,13 @@ private void FinishCollectingColumns()
624624 }
625625
626626 /// <summary>
627- /// Validates the pinned-column configuration and computes the sticky pixel offsets for each
628- /// pinned column. Rules enforced:
627+ /// Validates the pinned-column configuration and seeds initial sticky offsets for each
628+ /// pinned column before JavaScript recomputes them from rendered widths after first render.
629+ /// Rules enforced:
629630 /// <list type="bullet">
630- /// <item>Pinned columns must specify an explicit pixel <c>Width</c> (e.g., <c>"150px"</c>) .</item>
631- /// <item>Left -pinned columns must be contiguous at the beginning of the column list.</item>
632- /// <item>Right -pinned columns must be contiguous at the end of the column list.</item>
631+ /// <item>Pinned columns must specify an explicit <c>Width</c>.</item>
632+ /// <item>Start -pinned columns must be contiguous at the beginning of the column list.</item>
633+ /// <item>End -pinned columns must be contiguous at the end of the column list.</item>
633634 /// </list>
634635 /// </summary>
635636 private void ValidateAndComputePinnedColumns ( )
@@ -642,20 +643,20 @@ private void ValidateAndComputePinnedColumns()
642643
643644 ValidatePinnedColumnConstraints ( ) ;
644645
645- // Compute left -pin sticky offsets (cumulative left-to-right) .
646- var leftOffset = 0.0 ;
647- foreach ( var col in _columns . Where ( c => c . Pin == DataGridColumnPin . Left ) )
646+ // Compute start -pin sticky offsets in display order .
647+ var startOffset = 0.0 ;
648+ foreach ( var col in _columns . Where ( c => c . Pin == DataGridColumnPin . Start ) )
648649 {
649- col . PinOffsetPx = leftOffset ;
650- leftOffset += ParsePixelWidth ( col . Width ) ;
650+ col . PinOffset = $ " { startOffset . ToString ( CultureInfo . InvariantCulture ) } px" ;
651+ startOffset += ParsePixelWidth ( col . Width ) ;
651652 }
652653
653- // Compute right -pin sticky offsets (cumulative right-to-left) .
654- var rightOffset = 0.0 ;
655- foreach ( var col in _columns . Where ( c => c . Pin == DataGridColumnPin . Right ) . Reverse ( ) )
654+ // Compute end -pin sticky offsets in reverse display order .
655+ var endOffset = 0.0 ;
656+ foreach ( var col in _columns . Where ( c => c . Pin == DataGridColumnPin . End ) . Reverse ( ) )
656657 {
657- col . PinOffsetPx = rightOffset ;
658- rightOffset += ParsePixelWidth ( col . Width ) ;
658+ col . PinOffset = $ " { endOffset . ToString ( CultureInfo . InvariantCulture ) } px" ;
659+ endOffset += ParsePixelWidth ( col . Width ) ;
659660 }
660661 }
661662
@@ -665,52 +666,46 @@ private void ValidateAndComputePinnedColumns()
665666 /// </summary>
666667 private void ValidatePinnedColumnConstraints ( )
667668 {
668- // Width must be an explicit pixel value .
669+ // Width must be explicitly provided for pinned columns .
669670 foreach ( var col in _columns . Where ( c => c . Pin != DataGridColumnPin . None ) )
670671 {
671672 if ( string . IsNullOrWhiteSpace ( col . Width ) )
672673 {
673674 throw new ArgumentException (
674675 $ "Column '{ col . Title ?? col . Index . ToString ( CultureInfo . InvariantCulture ) } ' has Pin set but no Width. " +
675- "Pinned columns require an explicit Width in pixels (e.g., '150px')." ) ;
676- }
677-
678- if ( ! col . Width ! . Trim ( ) . EndsWith ( "px" , StringComparison . OrdinalIgnoreCase ) )
679- {
680- throw new ArgumentException (
681- $ "Column '{ col . Title ?? col . Index . ToString ( CultureInfo . InvariantCulture ) } ' has Pin set but Width '{ col . Width } ' is not in pixels. " +
682- "Pinned columns require an explicit Width in pixels (e.g., '150px')." ) ;
676+ "Pinned columns require an explicit Width." ) ;
683677 }
684678 }
685679
686- // Left -pinned columns must be contiguous at the start: each one must be preceded by
687- // another left -pinned column (or be the very first column).
680+ // Start -pinned columns must be contiguous at the start: each one must be preceded by
681+ // another start -pinned column (or be the very first column).
688682 for ( var i = 0 ; i < _columns . Count ; i ++ )
689683 {
690- if ( _columns [ i ] . Pin == DataGridColumnPin . Left && i > 0 && _columns [ i - 1 ] . Pin != DataGridColumnPin . Left )
684+ if ( _columns [ i ] . Pin == DataGridColumnPin . Start && i > 0 && _columns [ i - 1 ] . Pin != DataGridColumnPin . Start )
691685 {
692686 throw new ArgumentException (
693- $ "Column '{ _columns [ i ] . Title ?? _columns [ i ] . Index . ToString ( CultureInfo . InvariantCulture ) } ' is left -pinned but the preceding column is not. " +
694- "Left -pinned columns must be contiguous at the start of the column list." ) ;
687+ $ "Column '{ _columns [ i ] . Title ?? _columns [ i ] . Index . ToString ( CultureInfo . InvariantCulture ) } ' is start -pinned but the preceding column is not. " +
688+ "Start -pinned columns must be contiguous at the start of the column list." ) ;
695689 }
696690 }
697691
698- // Right -pinned columns must be contiguous at the end: each one must be followed by
699- // another right -pinned column (or be the very last column).
692+ // End -pinned columns must be contiguous at the end: each one must be followed by
693+ // another end -pinned column (or be the very last column).
700694 for ( var i = 0 ; i < _columns . Count ; i ++ )
701695 {
702- if ( _columns [ i ] . Pin == DataGridColumnPin . Right && i < _columns . Count - 1 && _columns [ i + 1 ] . Pin != DataGridColumnPin . Right )
696+ if ( _columns [ i ] . Pin == DataGridColumnPin . End && i < _columns . Count - 1 && _columns [ i + 1 ] . Pin != DataGridColumnPin . End )
703697 {
704698 throw new ArgumentException (
705- $ "Column '{ _columns [ i ] . Title ?? _columns [ i ] . Index . ToString ( CultureInfo . InvariantCulture ) } ' is right -pinned but the following column is not. " +
706- "Right -pinned columns must be contiguous at the end of the column list." ) ;
699+ $ "Column '{ _columns [ i ] . Title ?? _columns [ i ] . Index . ToString ( CultureInfo . InvariantCulture ) } ' is end -pinned but the following column is not. " +
700+ "End -pinned columns must be contiguous at the end of the column list." ) ;
707701 }
708702 }
709703 }
710704
711705 /// <summary>
712706 /// Parses a CSS pixel value string such as <c>"150px"</c> and returns the numeric value.
713- /// Returns <c>0</c> if the string is null, empty, or not a valid pixel value.
707+ /// Returns <c>0</c> if the string is null, empty, or not a valid pixel value so JavaScript
708+ /// can recompute the final sticky offsets from rendered widths after first render.
714709 /// </summary>
715710 private static double ParsePixelWidth ( string ? width )
716711 {
@@ -1445,4 +1440,3 @@ private async Task ToggleExpandedAsync(TGridItem item)
14451440 }
14461441 }
14471442}
1448-
0 commit comments