Get all data suggest in grid

Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules
Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
User avatar
ashkufaraz
Posts: 162
Joined: Mon Sep 22, 2014 9:36 am
Country: Iran
Location: Iran,Yazd
Contact:

Get all data suggest in grid

Unread postby ashkufaraz » Wed Apr 19, 2017 4:00 pm

Hi
I has a grid that has one suggest control. suggest fill with query

Code: Select all

select id,name from table
.
how can with javascript get all option of suggest in grid?
رمضان کریم است
[email protected]

amosbatto
Posts: 5247
Joined: Mon Jun 22, 2009 10:28 am
Country: Bolivia
Location: La Paz

Re: Get all data suggest in grid

Unread postby amosbatto » Wed Apr 19, 2017 8:17 pm

You can use control.executeQuery() to get a complete list of all the options for a suggest box, but you will have to filter them to eliminate the options you don't want.

If you a Dynaform with:
- a suggest box with the ID "selectUser", which has the SQL query:
SELECT USR_UID, USR_USERNAME FROM USERS
- a grid with the ID "usersList", which has two fields:
- - textbox with the ID "userId"
- - textbox with the ID "username
- a button with the ID "fillGrid"

Add the following JavaScript to the DynaForm. When the "fillGrid" button is clicked, it adds all the options in the suggest box which match the current value in the suggest box.

Code: Select all

function populateGridFromSuggest() {
  var filter = $("#selectUser").getValue();
  var aOptions = getFieldById("selectUser").executeQuery();

  //clear the grid:
  var nRow = $("#usersList").getNumberRows()
  for (; nRow > 0; nRow--) {
    $("#usersList").deleteRow(nRow);
  }
 
  //repopulate the grid with the filtered options from the suggest box:
  for (var i in aOptions) {
    if (aOptions[i].text.search(filter) != -1) {
      $("#usersList").addRow([{value: aOptions[i].value}, {value: aOptions[i].text}]);
    } 
  }
}

$("#fillGrid").on("click",populateGridFromSuggest);

Here is a example DynaForm:
check suggest.json
(3.04 KiB) Downloaded 22 times
Amos B. Batto ♦ ProcessMaker Technical Documentation Writer & Forum Manager ♦ Cofounder of ILLA-A

User avatar
ashkufaraz
Posts: 162
Joined: Mon Sep 22, 2014 9:36 am
Country: Iran
Location: Iran,Yazd
Contact:

Re: Get all data suggest in grid

Unread postby ashkufaraz » Fri Apr 21, 2017 3:02 am

Thank you for replay
with this can get all option a suggest

Code: Select all

var aOptions = getFieldById("selectUser").executeQuery();

ok but
for suggest in grid how can do it?
This not worked

Code: Select all

var aOptions = getGridField("Grid",1,"selectUser").executeQuery();
رمضان کریم است
[email protected]


Return to “Developing processes & programming”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest