The checkbox in the grid does net work

Posted by: soraroid on 12 November 2024, 9:39 pm EST

    • Post Options:
    • Link

    Posted 12 November 2024, 9:39 pm EST

    Hello.

    The grid contains a checkbox column, but the checkbox does not work properly.

    1. When you check with the mouse, it is not checked immediately. It is checked only when you click on another cell or press Enter.

    2. If you check twice with the mouse, the checkbox is checked, but if you scroll the grid and go back, the checkbox will be cleared.

    I want it to be checked immediately when I click it with the mouse and for the value to remain regardless of scrolling.

    Please answer with an example source.

    Thank you.

  • Posted 13 November 2024, 1:34 pm EST

    Hi,

    I tested with the latest version 8.0.20242.965 and I was unable to replicate the issue at my end. Kindly refer to the attached sample that shows this behaviour.

    Could you kindly share us a sample replicating the issue? You could also modify the attached sample and share it with us replicating the issue.

    Regards,

    Ankit

    CheckBox_Column.zip

  • Posted 13 November 2024, 3:54 pm EST - Updated 13 November 2024, 4:04 pm EST

    Thank you very much for your reply.

    The sample you sent also doesn’t work.

    Even if you select ‘Is Enable’ in Home with the mouse and then immediately move the heel of the mouse, the check will be released.

    However, after checking and selecting the Enter key or Temp Field with the mouse, Scroll works well.

    Please check again.KakaoTalk_20241114_045732181.zip

  • Posted 17 November 2024, 8:55 pm EST

    Hi.

    This is the same as the comment above, but I’m curious how it’s progressing.

    I also have the latest version, and the same thing happens when I run the example source.

    I would also like to know if I can change the checkbox value with the space bar when the cell has focus.

    Please check again.

  • Posted 18 November 2024, 5:02 am EST - Updated 18 November 2024, 5:07 am EST

    Hi,

    Thanks for sharing the video with us. I was able to replicate the behaviour at my end. I am currently investigating the issue at my end.

    As a workaround, you could use the C1CheckBox in the GridColumn and then set the value for the CheckBox. Refer to the attached sample.

    <FlexGrid ItemsSource="forecasts" @ref="grid" Style="new C1Style() { Height = 300}"
              CellFactory="cellFactory" AutoGenerateColumns="false">
        <FlexGridColumns>
            @if (forecasts != null && forecasts.Length > 0)
            {
                foreach (var prop in typeof(WeatherForecast).GetProperties())
                {
                    if (prop.Name == "IsEnabled")
                    {
                        <GridColumn Header="@prop.Name" HorizontalAlignment="C1HorizontalAlignment.Center">
                            <CellTemplate>
                                @{
                                    var weatherForecast = context as WeatherForecast;
                                    <C1CheckBox IsChecked="weatherForecast.IsEnabled" IsCheckedChanged="@(v=> weatherForecast.IsEnabled = v.Value)"></C1CheckBox>
                                }
                            </CellTemplate>
                        </GridColumn>
                    }
                    else
                    {
                        <GridColumn Binding="@prop.Name" Header="@prop.Name"></GridColumn>
                    }
                }
            }
        </FlexGridColumns>
    </FlexGrid>

    Also, for setting the value of the CheckBox using the “Space” key, you could override the “OnKeyDown” method of the GridCellFactory, and then change the underlying value.

    Refer to the following code snippet:

        public class MyCellFactory : GridCellFactory
        {
            protected override bool OnKeyDown(KeyboardEventArgs e)
            {
                if (e.Code == "Space")
                {
                    // Here goes custom logic
                    GridCellRange cursorRange = Grid.CursorRange;
                    if (Grid.Columns[cursorRange.Column].Header == "IsEnabled")
                    {
                        WeatherForecast rowValue = ((WeatherForecast)(Grid.GetCellValue(GridCellType.Cell, cursorRange)));
                        bool isEnabled = (bool)(Grid.SelectedItem as WeatherForecast).IsEnabled;
                        (Grid.SelectedItem as WeatherForecast).IsEnabled = !isEnabled;
                        Grid.Refresh(GridCellType.Cell, cursorRange);
                        return false;
                    }
                }
                return base.OnKeyDown(e);
            }
        }

    Please note that currently the FlexGrid doesn’t handle the default behaviour of the browser on “Space” press and scrolls the Grid. You could check for the column “isEnabled” and then prevent this behaviour using the JavaScript.

    You could use the above solutions. Further, I will update you on the above behaviour after my investigations.

    Regards,

    Ankit

    CheckBox_Column.zip

  • Posted 19 November 2024, 1:17 am EST

    Hi,

    Regarding the behaviour that the CheckBox value is changed, I have also escalated the issue to the concerned dev team for further investigation. The internal tracking id for the escalated case is: C1XAML-37393.

    I have also escalated to the dev team to toggle the CheckBox value when the “Space” key is pressed. The internal tracking id for the same is C1XAML-37394.

    For now, you could use the workarounds provided in my earlier response. I will let you know when there is more information on the escalated cases from the dev team.

    Regards,

    Ankit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels