jQuery UI Widgets Forums Lists ComboBox this.replace is not a function on DataBind

Tagged: 

This topic contains 7 replies, has 2 voices, and was last updated by  Peter Stoev 9 years, 10 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author

  • HSE_MLang
    Participant

    Hello,

    i’m building a sharepoint application atm and have a problem with binding data to a combobox. This is the code i use to build up the source, adapter and the combobox:

    
    $(document).ready(function () {
    	var data = '[{"ID":"1","Username":"MH"}, {"ID":"13","Username":"TB"}]';
    	var src = {
    		datatype: 'json',
    		datafields:[
    			{name:'ID', type: 'int'},
    			{name:'Username', type: 'string'}
    		],
    		localdata:data
    	};
    
    	var dacmb_UserFilter = new $.jqx.dataAdapter(src,{
    		autoBind: true,
    		contentType: 'application/json; charset=utf-8'
    	});
    
    	$('#cmb_Userfilter_View').jqxComboBox({
    		theme: 'metro',
    		source: dacmb_UserFilter,
    		displayMember: 'Username',
    		valueMember: 'ID',
    		selectedIndex: 0,
    		width: 100,
    		height: 20
    	});
    });
    

    When i open the page (Sharepoint Webpart) i get an error:

    
    TypeError: this.replace is not a function
    return this.replace(/^\s+|\s+$/g, '');
    

    The complete function is from // MicrosoftAjax.js // Microsoft AJAX Framework.

    
    String.prototype.trim = function String$trim() {
        /// <summary locid="M:J#String.trim" />
        /// <returns type="String"></returns>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this.replace(/^\s+|\s+$/g, '');
    }
    

    I found a similar problem within this forum for a datagrid with comboboxcolumn, but the solution from this thread is not working in my case.

    It would be nice if someone could give me a hint about the problem.

    Using jQWidgets v3.2.2 and jQuery v1.10.2

    Thanks in advance

    M. Lang


    Peter Stoev
    Keymaster

    Hi M.Lang,

    I prepared a sample with the provided code: http://jsfiddle.net/X5Hfu/, but I am unable to reproduce a problem with it. Unfortunately, we are not aware what could be the issue when the code runs in sharepoint application.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    HSE_MLang
    Participant

    Hello again,

    i’ve tried the combobox with a normal array of values without any dataadapter between and this works without any problems. I suppose it has something to do with the dataadapter and espacially with the binding of displayMember and displayValue. The Microsoft AJAX Framework is no Sharepoint only dll. I think it can be used with .NET 4.x.

    It seems that this framework binds a special trim function to the elements that can not be used by jQwidgets. It is not really a SharePoint problem, the only problem with SharePoint is, that the Microsoft AJAX Framework seems to be essential to work with SharePoint.

    I placed the include tags for jQuery and jQWidgets within the header of the SP page but after this, the framework is linked and seems to overwrite the trim function.

    Anyway ist it possible that you can test jqwidgets with Sharepoint ? Microsoft offers a free Edition called Sharepoint Foundation this can be installed with a small modification on a normal workstation OS with windows 7 or windows 8.x. There is no need for a Windows Server OS.

    Greetings
    M. Lang


    Peter Stoev
    Keymaster

    Hi M. Lang,

    If you wish, you can send your erroneous sample to support@jqwidgets.com and we will look if we can do something for a future release.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    HSE_MLang
    Participant

    Hello again,

    i could reproduce the problem and found a solution for this. I’m using a webservice to get a JSON object. In this object all values with integers are not masked within quotes like a string.

    
    [{{"ID":1,"Username":"MH"}}, {{"ID":13,"Username":"TB"}}];
    

    This sources produces the function error. When i set the ID within quotes it works all fine.

    
    [{{"ID":"1","Username":"MH"}}, {{"ID":"13","Username":"TB"}}];
    

    I’m a littlebit irritated about this because, in the grid’s i use the same way of getting the source and i getting not this error. Integers are not masked with quotes. Perhaps this helps to do a closer inspection of the problem. I could deliver a sample project with sharepoint webpart if are any questions.

    Greetings
    M. Lang

    • This reply was modified 9 years, 10 months ago by  HSE_MLang.

    Peter Stoev
    Keymaster

    Hi M. Lang,

    Which version of jQWidgets do you use? I guess it is not the latest, because there is no problem with any of these sources. Ex: http://jsfiddle.net/jqwidgets/8wSdj/

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    HSE_MLang
    Participant

    Hello again,

    i’m using the actual version 3.3.0. I tried to make an example project but today i had no time for that. I would do that, when i’m back out of my vacation 🙂

    Thanks for your help and support until now.

    Greetings

    M. Lang


    Peter Stoev
    Keymaster

    Hi M. Lang,

    Ok, thanks for the feedback. We will continue testing and if we find out the issue, we’ll resolve it. In the meantime, you may try the sample I sent you.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.