Skip to content

Commit 0cb3e13

Browse files
docs(checkbox): fix indeterinateChanged example
1 parent c82bafb commit 0cb3e13

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

components/checkbox/events.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,31 +150,40 @@ The `OnChange` event fires every time the `Value` parameter changes. The key dif
150150

151151
## IndeterminateChanged
152152

153-
The `IndeterminateChanged` event fires every time the `Indeterminate` parameter changes.
153+
The `IndeterminateChanged` event fires every time the `Indeterminate` parameter changes. The component does this when the chekbox was indeterminate and the user clicks it to toggle it to a checked/unchecked state. If you toggle the parameter value yourself, the event will not be raised.
154154

155155
>caption Handle IndeterminateChanged event
156156
157157
````CSHTML
158-
@*Press the button to toggle the Indeterminate state*@
159-
160-
<TelerikButton Primary="true" OnClick="@(() => Indeterminate = !Indeterminate)"> Toggle Indeterminate </TelerikButton>
158+
@* Click the checkbox when it is indeterminate to toggle its state to see when the event fires. *@
161159
160+
<div class="m-3">
161+
Checkbox is checked: @CheckBoxValue
162+
<br />
163+
@result
164+
</div>
162165
<div class="mt-2">
163-
<strong class="text-muted">Indeterminate checkbox</strong>
164-
<TelerikCheckBox @bind-Value="@IndeterminateValue"
166+
<label for="theCb" class="text-muted">Indeterminate checkbox</label>
167+
<TelerikCheckBox @bind-Value="@CheckBoxValue" Id="theCb"
165168
Indeterminate="@Indeterminate"
166169
IndeterminateChanged="((bool val) => ChangeHandler(val))">
167170
</TelerikCheckBox>
168171
</div>
172+
<TelerikButton Primary="true" OnClick="@(() => Indeterminate = !Indeterminate)"> Toggle Indeterminate </TelerikButton>
169173
170174
@code{
171-
public bool Indeterminate { get; set; }
172-
public bool IndeterminateValue { get; set; }
175+
bool Indeterminate { get; set; } = true;
176+
bool CheckBoxValue { get; set; }
177+
178+
string result { get; set; }
173179
174180
void ChangeHandler(bool value)
175181
{
182+
// make sure to set the model value, two-way binding does not update it automatically
176183
Indeterminate = value;
184+
185+
result = $"Indeterminate state changed to {value} on <strong>{DateTime.Now}</strong>";
177186
}
178187
}
179188
````
180-
![Toggle Indeterminate state](images/checkbox-toggle-indeterminate-state.gif)
189+
Binary file not shown.

components/checkbox/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The CheckBox provides the following features:
4242
* `Value` and `bind-Value`- mapped to the `Checked` property of the normal HTML checkbox
4343
* The `Value` and `bind-Value` accept `bool` and `bool?` types
4444
* `Indeterminate` and `bind-Indeterminate` - see the [Indeterminate state]({%slug checkbox-indeterminate-state%}) article for more information and examples
45-
* `IndeterminateChanged` - see the [CheckBox events]({%slug checkbox-events%}) article for more information and example
45+
* Events - see the [CheckBox events]({%slug checkbox-events%}) article for more information and examples.
4646
* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article for more details.
4747

4848
## Examples

0 commit comments

Comments
 (0)