This is a migrated thread and some comments may be shown as answers.

Set Checkbox based on textbox contents

3 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 01 Apr 2019, 03:56 AM
I have an inCell Edit grid that has a bound field and a bound checkbox.   When in edit mode, if a change is made to the textbox I want to test the value.   If length(textbox) > 0, set checkbox true, if length(textbox)=0, set checkbox false.    Is this possible?

3 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetomir
Telerik team
answered on 01 Apr 2019, 01:45 PM
Hi Bill,

Any of the model's properties could be modified programmatically via the set() method. I can suggest executing the custom logic within the Save event handler. It is triggered after the user has made the changes and focuses out of the editable cell. More information can be found here:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/save

What I can suggest is to check if there is a value within the textbox and based on the outcome, change the state of the boolean value:

.Events(ev=>ev.Save("onSave"))

<script>
    function onSave(e) {
        if (e.values.ShipCity.length > 0) {
            e.model.set("Discontinued", true);
        } else {
            e.model.set("Discontinued", false);
        }
    }
</script>

Give the suggestion a try and let me know how it works out for you.


Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Bill
Top achievements
Rank 1
answered on 01 Apr 2019, 02:49 PM

Thank you very much.   Exactly what I was trying to do!

I did spend almost 2 days trying  to figure it out on my own (I am a bit stubborn).   I had made various attempts at achieving my outcome using e.container.find and grid.dataItem.   I had not thought to use model (in large part cuz I'm a newbie to Core and Kendo).   Is there a simple answer to use "container" when .... and "dataItem" when...  and "model" when...   Hopefully that question isn't too odd and off base (if so you can ignore me :-))  

0
Accepted
Tsvetomir
Telerik team
answered on 04 Apr 2019, 08:28 AM
Hi Bill,

Generally, there is not a strict use-case for each of the functionalities that are provided by the Kendo UI Grid. The usage of the different properties and models is rather per-case. When the model is not directly provided via the event arguments, you can get a reference to the current row and pass it to the dataItem() method. This would return the data item. 

The event arguments which are available for each of the grid's events are listed in our API documentation section. For instance, the save event has several event arguments which are listed in the article and usually there is clarification to each of them. Based on the arguments you can draw a conclusion of whether you would have to access the item of interest via a different approach.

If you have a more specific question and a use-case, I will be happy to provide you with additional details.


Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Bill
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Bill
Top achievements
Rank 1
Share this question
or