jQuery UI Widgets Forums Plugins Data Adapter jqxDataAdapter and updaterow method

This topic contains 5 replies, has 2 voices, and was last updated by  Hristo 8 years, 4 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • jqxDataAdapter and updaterow method #88110

    Maurizio0015
    Participant

    I have four simple objects: a source, a jqxDataAdapter, a jqxInput and a jqxButton.

    The source, through a call, fills a jqxInput.
    After changing the value of the jqxInput and press the ‘Update’ button, i want to be called the method ‘updaterow’ of my source.

    How can I do?

    This is my code:

    
        $(document).ready(function () {
    
            var row = {};
            row["Id"] = 3055;
    
            var getdescription = "@GetDescription";
            var updatedescription = "@UpdateDescription";
            var source =
        {
            datatype: "json",
            datafields: [
                 { name: 'id', type: 'int' },
                 { name: 'descrizione', type: 'string' }
            ],
            id: 'id',
            url: getdescription,
            async: false,
            updaterow: function (rowid, rowdata, commit) {
                rowdata.Id = rowid;
                $.ajax({
                    dataType: 'json',
                    cache: false,
                    data: rowdata,
                    url: updatedescription,
                    type: "POST",
                    success: function (data, status, xhr) {
                        commit(true);
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.statusText);
                        commit(false);
                    }
                });
            }
    
        };
            
            var adapter = new $.jqx.dataAdapter(source);
            adapter.dataBind();
            $("#jqxId").jqxInput();
            $("#jqxDescrizione").jqxInput();
            $("#jqxId").jqxInput('val', adapter.records[0].id);
            $("#jqxDescrizione").jqxInput('val', adapter.records[0].descrizione);
    
            $("#jqxUpdate").jqxButton();
            $("#jqxUpdate").bind('click', function () {
                row["Id"] = 3055;
                row["Descrizione"] = $("#jqxDescrizione").val();
                
                //How can i call the 'updaterow' method of my source, here?
    
            });
    
        });
    
    jqxDataAdapter and updaterow method #88140

    Hristo
    Participant

    Hello Maurizio0015,

    This ‘updaterow’ member is part of the source of others Widgets.
    I would like to suggest demo that could be useful:
    http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxinput/remoteautocomplete.htm?light
    Also this example, there you could find way to control the typed data in the Input:
    http://jsfiddle.net/jqwidgets/BcYMU/

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    jqxDataAdapter and updaterow method #88150

    Maurizio0015
    Participant

    Hi Hristo,
    i do not want to check the input data, but proceed to storing them on my database.

    I solved by eliminating the ‘updaterow’ method from the source and entering the ajax call in the point of my interest, as shown here:

    
    $("#jqxUpdate").bind('click', function () {
                row["Id"] = 3055;
                row["Descrizione"] = $("#jqxDescrizione").val();
                
                row.Id = 3055;
                $.ajax({
                    dataType: 'json',
                    cache: false,
                    data: row,
                    url: updatedescription,
                    type: "POST",
                    success: function (data, status, xhr) {
                        commit(true);
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.statusText);
                        commit(false);
                    }
                });
    
            });
    
    

    I wanted to ask you if you want to extend the jqxDataAdapter object so that it can contain within itself the ability to recall the three classic CRUD methods that may contain the source (‘addrow’, ‘updaterow’, ‘deleterow’).

    In this way, any jqWidgets object may have a source not only in reading, but also in the modification and deletion, delegating to jqxDataAdapter the opportunity to call them.

    Could you give me more information about this?

    Best regards,
    Maurizio.

    jqxDataAdapter and updaterow method #88176

    Hristo
    Participant

    Hello Maurizio,

    We have many other options to communicate with the server.
    (You could take a look at those members – processData, formatData, beforeSend, loadServerData)
    You could use AJAX for different queries.
    Also, I would like to suggest you this example:
    http://www.jqwidgets.com/jquery-widgets-demo/demos/php/login_form.htm?light

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    jqxDataAdapter and updaterow method #88192

    Maurizio0015
    Participant

    Hi Hristo,
    i thank you for your interest.
    I think the jqxDataAdapter is not necessary for my purpose.

    I can define two AJAX functions: one for data loading and one for their updateing, and remove the jqxDataAdapter whose true function is to interface more complex objects such as jqxGrid.

    I understood correctly?

    Best Regards,
    Maurizio.

    jqxDataAdapter and updaterow method #88232

    Hristo
    Participant

    Hello Maurizio,

    Yes, this is what I mean.
    Thank you for your understanding.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.