jQuery UI Widgets Forums Grid Grid – Issuse in handling Special character

This topic contains 6 replies, has 2 voices, and was last updated by  Hristo 7 years, 10 months ago.

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

  • jkapasi
    Participant

    Hello,
    I have issue in handling special characters
    steps I follow:
    STEP 1 : I use encodeURIComponent() to encode the special characters (!@#$%^&*()_+{}”:>?<) and save it to db
    Steps : Because my datatype for the Grid is json even if I decode the data and apply to jqxGrid it dies. I think because json uses “{}” braces that’s way it treats the special character {} as json format.
    Any assistance is much appreciated.


    Hristo
    Participant

    Hello jkapasi,

    I would like to suggest you check the received data.
    You could try to use loadError(jqXHR, status, error) callback of the DataAdapter to check for any error message.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    jkapasi
    Participant

    Hello,
    I Appreciate for your help
    But Let me put the question in other way … Is there any API to Decode the data when the data is being attach to jqxGrid.

    and the error it is throwing is jsondata which I m passing it to jqxGrid. the json is as follows :

    "[{\"TotalRows\":\"2\"},
    {\"Rows\":[
    {
    	\"SDE_NAME\":\"MN-25343\",
    	\"SDE_DFS_001\":\"!@#$%%^&^&&**(()_+{}\":?><\",
    	\"SDE_DFS_002\":\"zxczfzcfzxczx\",
    	\"SDE_DFS_003\":\"\",
    	\"SDE_DFS_004\":\"\",
    	\"SDE_DFS_005\":\"siddhi\",
    	\"SDE_DFS_006\":\"null\",
    	\"SDE_DFS_007\":\"\",
    	\"SDE_DFSI_001\":\"MW-LIAS-BE-APP-VM\",
    	\"SDE_DFSI_002\":\"Registration\",
    	\"SDE_DFSI_003\":\"0002019\",
    	\"SDE_DFSI_004\":\"null\",
    	\"SDE_DFSI_005\":\"null\",
    	\"SDE_DFII_001\":\"Open\",
    	\"SDE_DFII_002\":\"Low\",
    	\"SDE_DFII_003\":\"Action\",
    	\"SDE_DFD_001\":\"2017-1-31\",
    	\"SDE_DFD_002\":\"null\",
    	\"SDE_DFD_003\":\"\",
    	\"SDE_DFD_004\":\"2017-1-23\",
    	\"SDE_TYPE\":\"BE_MEMO_NOTES\"
    },
    {
    	\"SDE_NAME\":\"MN-25342\",
    	\"SDE_DFS_001\":\"Gdfgfg\",
    	\"SDE_DFS_002\":\"gdfgdfg\",
    	\"SDE_DFS_003\":\"\",
    	\"SDE_DFS_004\":\"\",
    	\"SDE_DFS_005\":\"siddhi\",
    	\"SDE_DFS_006\":\"null\",
    	\"SDE_DFS_007\":\"\",
    	\"SDE_DFSI_001\":\"MW-LIAS-BE-APP-VM\",
    	\"SDE_DFSI_002\":\"Registration\",
    	\"SDE_DFSI_003\":\"0002019\",
    	\"SDE_DFSI_004\":\"null\",
    	\"SDE_DFSI_005\":\"null\",
    	\"SDE_DFII_001\":\"Open\",
    	\"SDE_DFII_002\":\"Low\",
    	\"SDE_DFII_003\":\"Action\",
    	\"SDE_DFD_001\":\"2017-1-31\",
    	\"SDE_DFD_002\":\"null\",
    	\"SDE_DFD_003\":\"\",
    	\"SDE_DFD_004\":\"2017-1-17\",
    	\"SDE_TYPE\":\"BE_MEMO_NOTES\"
    }]
    }]"

    Hristo
    Participant

    Hello jkapasi,

    Please, take a look at this example:
    https://www.jseditor.io/?key=grid-decoding
    Hope this helps.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    jkapasi
    Participant

    Hello,

    I tried running the demo in the link you specified. But, in the console, it gives following error:

    Error: Invalid character

    Please help me solve this problem of handling special characters in the grid.

    Thank You.

    Regards
    Jash


    jkapasi
    Participant

    Hello,
    I did some changes in your code and it worked. Blow is the changed code

    $(document).ready(function () {
        var jsonData = '[{\"TotalRows\":\"2\"},' +
            '{\"Rows\":[' + 
            '{  \"SDE_NAME\":\"MN-25343\", \"SDE_DFS_001\":\"!@#$%%^&^&&**(()_+{}\\\\\\":?><\", \"SDE_DFS_002\":\"zxczfzcfzxczx\"},{ \"SDE_NAME\":\"MN-25342\", \"SDE_DFS_001\":\"Gdfgfg\",\"SDE_DFS_002\":\"gdfgdfg\"}]}]';
        
        //jsonData = JSON.parseJSON(jsonData);
        
        var source = {
            localdata: jsonData,
            datafields: [{
                name: 'SDE_NAME',
                type: 'string',
                map: ''
            }, {
                name: 'SDE_DFS_001',
                type: 'string'
            }, {
                name: 'SDE_DFS_002',
                type: 'string'
            }],
            root: 'Rows',
            datatype: "json"
        };
        
        var dataAdapter = new $.jqx.dataAdapter(source, {
            beforeLoadComplete: function (records)
            {
                console.log(records);
                return records;
            },
            loadComplete: function ()
            {
                console.log("loadComplete");
            }
        });
        
        $("#jqxgrid").jqxGrid(
        {
            width: 850,
            source: dataAdapter,
            autoheight: true,
            columns: [
                { text: 'SDE NAME', datafield: 'SDE_NAME' },
                 { text: 'SDE DFS 001', datafield: 'SDE_DFS_001' },
               { datafield: 'SDE_DFS_002' }
            ]
        });
    });

    Hristo
    Participant

    Hello Jash,

    I assume that this case has been resolved?
    If you need additional help feel free to contact us.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.