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

how to override KendoListView function! Urgent Please!

1 Answer 335 Views
ListView
This is a migrated thread and some comments may be shown as answers.
ScholarisPM
Top achievements
Rank 1
ScholarisPM asked on 12 Nov 2013, 02:18 AM
Hi Support Team,

I had a big issue when using KendoListView function on windows 8 platform. The issue is window 8 platform doesn't allow us add dynamic html that contain unsafe code. 

I made a search and found out this link:
http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx

This is extracting from the article:
"Dynamically adding HTMLA page
in your app's local context has more access to the system than other Web pages (or "Web-context pages") do. It can access the Windows Runtime and, depending on the app's permissions, might be able to access the file system and your devices. For this reason, it's important to prevent potentially malicious code from executing.To guard against script injections and help shield your system from potentially malicious code, HTML you inject into a page in the local context is filtered as though it was processed by the toStaticHTML method. Injecting HTML that contains an unknown element, event handler, script or reference to script, or unknown CSS pseudo-element and pseudo-class causes an exception when you try to add the HTML to the page's DOM."

We can work around by placing the block of code in the function MSApp.execUnsafeLocalFunction as following:
MSApp.execUnsafeLocalFunction(function () {
                        var listView = $("#listView").kendoListView({
                            dataSource: localDataSource,
                            selectable: 'single',
                            template: kendo.template($("#CountryListView_template").html())
                        });
                    });

But this method is not good as we must change code of the whole process to make it work. So I need to override the kendoListView function to make it affect for the whole project without much code changes.

I tried this one:

 _kendoListView = $.fn.kendoListView;
 $.fn.kendoListView = function (i) {
       var _this = this;
        MSApp.execUnsafeLocalFunction(function () {
            _kendoListView.apply(_this, arguments);
        });
        
    }

But it doesn't work. Would you please help me how to override this function above. i just want to add the code MSApp.execUnsafeLocalFunction before call KendoListView function. 

Thanks and Best Regards,
Craig,

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 13 Nov 2013, 03:27 PM
Hello ScholarisPM,

I suggest you to use the call method. For example:
_kendoListView = $.fn.kendoListView;
$.fn.kendoListView = function(options) {
    var that = this;
    setTimeout(function() {
        _kendoListView.call(that, options);
    }, 300);
}

Please change the setTimeout with the required for your case method and give it a try.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ListView
Asked by
ScholarisPM
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or