continue on autocomplete for table column

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

continue on autocomplete for table column

#1

Postby xren » Tue Oct 22, 2013 8:38 pm

Hi Wai and Jon,

I think I find the problem now.
I have two table rows, row1 column1, row2 column1.
I set table column1 with class identifier 'medSearch'
and have autocomplet on column 1 then.

For first row, it works fine.
For second row, my autocomplete code triggered as well.
But in my autocomplete code, I need to get row2 column1's user input as search criteria.
However, in my code I use
var searchStr = $(".medSearch").val();

Then it always return the first item which has .medSearch class identifier, then I will always get the same search string. then then the same result. How can I set the html properties to have the value form the current row?

Thank you for your help in advance.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Wed Oct 23, 2013 8:06 am

That's a jQuery question. I think you can do this:

$(this).val();

but I haven't tested it. For this to work $(this) has to return the <input> element for your column.
0 x

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

#3

Postby xren » Wed Oct 23, 2013 3:00 pm

Hi Jon,

Thank you for your reply.

I received help from other forum about javascript and jquery.
The way of doing it is use the following in my autocomplete code.

var searchStr = request.term;

It works fine for that part.

But I am facing the other problem: there are other two columns need to be populated by the result of the autocomplete. I use .medCode and medDin as class identifier for these two columns. and the code in autocomplete is

myTable.push({
label: $(childList[0]).text() + " - " + $(childList[2]).text(),
value: $(childList[0]).text(),
din: $(childList[2]).text(),
code: $(childList[1]).text()
});

select: function(event,ui) {
$(".medCode").val(ui.item.code);
$(".medDin").val(ui.item.din);
},

Then after I select one item in the list, the two columns of all rows are set with value corresponding to the current selected item.

I think it is similar to my previous question.

If you have any idea about how to fix it please let me know.

Thank you,
Xiaoli
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Wed Oct 23, 2013 3:09 pm

Xiaoli,

You need to address these extra columns via jQuery by navigating up to the table row - <tr> - then navigating back down to the correct cell. Will be something like this:

Code: Select all

$&#40;this&#41;.parent&#40;&#41;.parent&#40;"td"&#41;.parent&#40;"tr"&#41;.find&#40;".medCode"&#41;.val&#40;ui.item.code&#41;; 
The exact sequence of parent() calls might need to be changed to match your form - you should be able to see this in the HTML source.

Regards
Jon
0 x

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

#5

Postby xren » Fri Oct 25, 2013 4:12 pm

Hi Jon,

You are right. I use
$(this).closet('tr').find(".medCode").val();

in the select code. It works fine now.

Thank you Jon.

However, the rows added by addRow cannot be recognized by ebase backend script. Can you help on this?

Thanks,
Xiaoli
0 x

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

#6

Postby xren » Fri Oct 25, 2013 5:34 pm

Continue:

Or my question is: what is the different of
calling insertrow to med table in before page script and in the script after the form is rendered and user clicks add button.

The auto complete works fine on the rows for first case but stopped working totally after user clicked add button - a new row is added.

Xiaoli
0 x


Who is online

Users browsing this forum: No registered users and 28 guests