jQWidgets Forums

jQuery UI Widgets Forums General Discussions Setting current value in jqxInput

This topic contains 7 replies, has 4 voices, and was last updated by  upstate18 5 years, 9 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • Setting current value in jqxInput #18366

    greg.o
    Member

    Hi All,

    I am trying to use jqxInput to support a dynamic lookup in an SQL table that contains about 6000 entries so I chose jqxInput based on its use of the dataAdapter – the problem is I can’t get it to set the current value…

    My code is ( I am using PHP substitution for $this variables so they’re ok)….

    _currval”>

    $(document).ready(function () {

    $(“#ctl$n”).jqxInput(
    {
    width: 250,
    height: 25,
    displayMember: “name”,
    valueMember: “id”,
    source: function (query, response) {
    var dataAdapter = new $.jqx.dataAdapter(
    {
    datatype: “json”,
    datafields: [
    { name: ‘name’, type: ‘string’},
    { name: ‘id’, type: ‘string’}
    ],
    url: ‘$personSearch’,
    id: ‘id’,
    root: ‘Result’,
    data: { query : “$this->_currval” }
    },
    {
    autoBind: true,
    formatData: function (data) {
    data.query = query;
    return data;
    },
    loadComplete: function (data) {
    d = data.Result;
    if (d.length > 0) {
    var r = new Array();
    for (i=0;i<d .length;i++) {
    r[i] = d[i].name + '’;
    }
    response(r);
    }
    }
    }
    );
    }
    });

    $(“#ctl$n”).jqxInput(‘query’,’$this->_currval’ );

    $(“#ctl$n”).on(“change”, function(event) {
    var val = $(“#ctl$n”).val();
    var st = val.lastIndexOf(“”);
    var x = val.substring(st+1,ed);
    $(“#ret$n”).val(x);
    });

    });

    The error I get from javascript… “Uncaught invalid property: query”

    I have tried setting various things – have set an initial value in the query string – but there seems no way to trigger the source function as an initialisation of the input…

    Any help gratefully accepted…

    Thanks
    Greg

    Setting current value in jqxInput #18368

    Peter Stoev
    Keymaster

    Hi Greg,

    Here’s a blog post about that topic: http://www.jqwidgets.com/remote-auto-complete-using-jqxinput/

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Setting current value in jqxInput #18383

    greg.o
    Member

    Thanks Peter. I’ve already read that one – the fundamental problem is I want to select one value on start of the page – how do I do that?

    Thanks
    Greg

    Setting current value in jqxInput #18385

    Peter Stoev
    Keymaster

    Hi Greg,

    To set a value in jqxInput, use $(“#input”).val(“Your Value”);

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Setting current value in jqxInput #18470

    greg.o
    Member

    Thanks again, Peter. I guess what I meant was how do I set the inputValue and then get the source function to retrieve… I decided just to set the placeHolder and leave it at that … works much the same… I use a hidden input to hold the id of the foreign key table to return it to the form anyways…

    Thanks
    Greg

    Setting current value in jqxInput #95747

    kiluakun
    Participant

    Hi, i have a similar problem.
    Whenever a user inputs a value that’s not one of the list available, the .val of the jqxInput returns the last “correct” value, for example, if i type a “correct” name of a customer, it stores the values for that customer, but if my following action is to type a non existing customer, and then try to get the value of the input, i get the former value, the one from the existing customer. I’ve tried getting the actual/current value, but all i get, is the last matched value. What can i do?

    Setting current value in jqxInput #95749

    Peter Stoev
    Keymaster

    You can use the value property of Inputs.

    Setting current value in jqxInput #106116

    upstate18
    Participant

    I believe this is what you’re looking for.

    $(‘#jqxInput’).jqxInput(‘val’, {label: labelcolumn, value: valuecolumn});

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

You must be logged in to reply to this topic.