kendoGrid cannot works without 'async:false'

0 Answers 47 Views
Grid
1
Top achievements
Rank 1
1 asked on 05 Sep 2024, 07:44 AM

when jquery is 1.X,we can do like this



<script>
        $(document).ready(function () {
            $("#grid").kendoGrid({
                dataSource: dataSource,
                columns: [{
                    field: "ContactName",
                    title: "Contact Name",
                    values: getDictName('type')
                }, {
                    field: "ContactTitle",
                    title: "Contact Title"
                }]
            });
			function getDictName(type){
			   $.ajax({
			   url:"demo.action",
			   success:function(result){
                      return result;//the result like:[{key:'a',value:'apple'},{key:'o',value:'orange'}]
                }});
			}
			
        });
    </script>

but when we change jquery to 3.X, the function of 'getDictName' is not work,because jquery-3.x is not support for 'async:false', so before the function-getDictName returned the result, the kendoGrid is already performed.

Nikolay
Telerik team
commented on 10 Sep 2024, 07:27 AM

Hello,

Indeed, as of jQuery 1.8, the async: false is deprecated. You will have to workaround it, for example:

$(document).ready(function () {
             var values = getDictName();
	     function getDictName(type){
		 $.ajax({
			url:"demo.action",
			success:function(result){
                               return result;
                        }
                 }).done(function() {
                        $("#grid").kendoGrid({
                               dataSource: dataSource,
                               columns: [{
                               field: "ContactName",
                               title: "Contact Name",
                               values: values
                               }, {
                               field: "ContactTitle",
                               title: "Contact Title"
                               }]
                        });
                 });
	     }		
        });

Regards,

Nikolay

No answers yet. Maybe you can help?

Tags
Grid
Asked by
1
Top achievements
Rank 1
Share this question
or