jQWidgets Forums

jQuery UI Widgets Forums Grid url action from jqxgrid source can't run

This topic contains 4 replies, has 2 voices, and was last updated by  fenderEvrby 11 years, 1 month ago.

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

  • fenderEvrby
    Participant

    Hi,
    I have an jqxgrid control which updates some values into a database. It has an checkbox column than if it is checked, the value of columns Value 1 and Value 2 must be marged into a variable. Anyway, it works perfectly if updates a couple of values, but if there are many of them it simply doesn’t run. Here is my code:

    $(“.update”).click(function () {
    var items = $(‘#jqxgrid’).jqxGrid(‘getrows’);
    var myArray = [];
    var arrayRoutes = [];
    var arraySku = [];
    var arrayPedidos = “”;
    var cantidad = 0;
    var restante = 0;
    var val = 0;
    var arrayRestante = [];
    var item = $(“#list2”).jqxDropDownList(‘getItems’);

    $.each(item, function (index) {
    arrayRoutes.push(this.label);
    });

    $.each(items, function (index) {
    if (this.SELECTION) {
    myArray.push(‘<desc>’ + this.VALUE1 + ‘</desc>’ + ‘:’ + this.VALUE2 + ‘;’);

    }
    });

    if (myArray.length == 0) {
    new Messi(‘You must select a value’, { title: ‘Warning’, titleClass: ‘anim warning’, modal: true, buttons: [{ id: 0, label: ‘OK’, val: ‘X’}] });
    return false
    }
    else {
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘SELECTION’, type: ‘bool’ },
    { name: ‘VALUE1’, type: ‘string’ },
    { name: ‘STATUS’, type: ‘char’ },
    { name: ‘VALUE2’, type: ‘string’ }
    ],
    id: ‘id’,
    traditional: true,
    url: ‘@(Url.Action(“UpdateValue”,”api/WebApi”))’,
    data: ({ param1: $(“#Param1”).val(), date: $(“#jqxWidget”).val(), values: myArray, routes: arrayRuotes, status: $(“#Status”).val(), filter: $(“#Filter”).val() }),
    type: ‘GET’
    };
    var dataAdapter = new $.jqx.dataAdapter(source);

    $(“#jqxgrid”).jqxGrid(
    {
    width: 1320,
    height: 350,
    source: dataAdapter,
    enabletooltips: true,
    pageable: false,
    theme: ‘ui-smoothness’,
    rowdetails: false,
    filterable: true,
    filtermode: ‘excel’,
    showfilterrow: true,
    columnsresize: true,
    editable: true,
    columns: [
    { text: ‘Selection’, datafield: ‘SELECTION’, columntype: ‘checkbox’, width: 120 },
    { text: ‘Value 1’, datafield: ‘VALUE1’, width: 130, editable: false, filtertype: ‘checkedlist’ },
    { text: ‘Status’, datafield: ‘STATUS’, width: 120, editable: false, filtertype: ‘checkedlist’ },
    { text: ‘Value 2’, datafield: ‘VALUE2’, width: 130, editable: false, filtertype: ‘checkedlist’ },
    ]
    });
    }
    });

    Any sugestion?
    Thanks anyway!!


    Peter Stoev
    Keymaster

    Hi fenderEvrby,

    May be you should use POST instead of GET because with GET you have restriction of ~2000 characters which you can pass with the URL depending on the browser.

    Best Regards,
    Peter Stoev

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


    fenderEvrby
    Participant

    Hi, Peter. Thanks for your help. I modified the code as you suggested but it is still not running. I tried to use a loop before the var source
    and I used the ‘valueToProcess’ variable in the data attribute of the source variable. Here is the code:

    $.each(myArray, function (index) {
    var valueToProcess = myArray[index];
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘SELECTION’, type: ‘bool’ },
    { name: ‘VALUE1’, type: ‘string’ },
    { name: ‘STATUS’, type: ‘char’ },
    { name: ‘VALUE2’, type: ‘string’ }
    ],
    id: ‘id’,
    traditional: true,
    url: ‘@(Url.Action(“UpdateValue”,”api/WebApi”))’,
    data: ({ param1: $(“#Param1″).val(), date: $(“#jqxWidget”).val(), values: valueToProcess, routes: arrayRuotes, status: $(“#Status”).val(), filter: $(“#Filter”).val() }),
    type: ‘GET’
    };
    ……………..

    When I test my code, it sends me the next error: “Microsoft JScript runtime error: unable to get value of property ‘0’: object is null or undefined”

    Can you help me?
    Thanks anyway!!


    Peter Stoev
    Keymaster

    My suggestion actually was to use “POST” instead of “GET”

    Best Regards,
    Peter Stoev

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


    fenderEvrby
    Participant

    Sorry, my mistake. I forgot to paste that part of code in my last post, but the rest is the same and behavior as I described. Here is the code updated with “POST”

    $.each(myArray, function (index) {
    var valueToProcess = myArray[index];
    var source =
    {
    datatype: “son”,
    datafields: [
    { name: ‘SELECTION’, type: ‘bool’ },
    { name: ‘VALUE1’, type: ‘string’ },
    { name: ‘STATUS’, type: ‘char’ },
    { name: ‘VALUE2’, type: ‘string’ }
    ],
    id: ‘id’,
    traditional: true,
    url: ‘@(Url.Action(“UpdateValue”,”api/WebApi”))’,
    data: ({ param1: $(“#Param1”).val(), date: $(“#jqxWidget”).val(), values: valueToProcess, routes: arrayRuotes, status: $(“#Status”).val(), filter: $(“#Filter”).val() }),
    type: ‘POST’
    };
    ………………

    It sends next error: “Microsoft JScript runtime error: unable to get value of property ’0′: object is null or undefined”.
    Actually, it only updates 1 field into the database and then sends the error it put above.

    Thanks!!

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

You must be logged in to reply to this topic.