Angular UI Grid: how to fill a dropdown filter with real data from database/backendHow to display length of filtered ng-repeat dataNotify change of angular service in function when function defined as propertyangular ui grid column dropdown filter blank optionAngular UI-Grid with bootstrap action dropdown in cellTemplateHow to create a searchable dropdown in UI Grid using angular js?Best practice to fill dropdowns in Angularangular ui grid single filter + cellfilterAngular UI-Grid filteringhow to keep the data as filtered and sorted from angular ui-grid and export it?Get filtered data from ui-grid in controller

tikz convert color string to hex value

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Malformed Address '10.10.21.08/24', must be X.X.X.X/NN or

What is the word for reserving something for yourself before others do?

Did Shadowfax go to Valinor?

A case of the sniffles

Do I have a twin with permutated remainders?

Java Casting: Java 11 throws LambdaConversionException while 1.8 does not

How is it possible to have an ability score that is less than 3?

Languages that we cannot (dis)prove to be Context-Free

Why doesn't H₄O²⁺ exist?

Does an object always see its latest internal state irrespective of thread?

Intersection point of 2 lines defined by 2 points each

What would happen to a modern skyscraper if it rains micro blackholes?

How much RAM could one put in a typical 80386 setup?

Can I make popcorn with any corn?

Can a Cauchy sequence converge for one metric while not converging for another?

Cross compiling for RPi - error while loading shared libraries

How to determine what difficulty is right for the game?

What's that red-plus icon near a text?

What's the point of deactivating Num Lock on login screens?

Why is consensus so controversial in Britain?

Character reincarnated...as a snail

Watching something be written to a file live with tail



Angular UI Grid: how to fill a dropdown filter with real data from database/backend


How to display length of filtered ng-repeat dataNotify change of angular service in function when function defined as propertyangular ui grid column dropdown filter blank optionAngular UI-Grid with bootstrap action dropdown in cellTemplateHow to create a searchable dropdown in UI Grid using angular js?Best practice to fill dropdowns in Angularangular ui grid single filter + cellfilterAngular UI-Grid filteringhow to keep the data as filtered and sorted from angular ui-grid and export it?Get filtered data from ui-grid in controller






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I've been struggling for more than 1 day trying to find a solution to pre-fill angular-ui-grid dropdown with data from the backend. And yes, I've seen many similar questions, but none of them talks about filling a selectOption with real data from backend.



It works fine with a pre-defined array like this: $scope.tiposArquivoSelecionados = [ value: 1, label: 'First', value: 2, label: 'Second', value: 3, label: 'Third'];



enter image description here



But when I try to fill the selectOption with data gathered from backend, the selectOption is not displayed. Take a look:



enter image description here



The data is gathered successfully, the grid is rendered successfully, what makes me think it's a timing problem.



Here is a list of a few workarounds I tried (all failed) to solve the possible timing problem:



  • refresh the grid after gathering the data;

  • put the columnDefs inside the service success callback

  • put a ng-if in the .html to display the grid only if the array.length > 0

None of them worked =/




selectOptions array declaration:



$scope.tiposArquivoGridSelectOptions = [];


Code from the GridOptions.columnDefs:




field: 'controleArquivoId',
name: 'Tipo de Arquivo',
cellClass: 'ui-grid-cell-padding',
enableFiltering: true,
enableSorting: true,
enableHiding: true,
filter:
type: uiGridConstants.filter.SELECT,
selectOptions: $scope.tiposArquivoGridSelectOptions,
,
sort:
direction: uiGridConstants.ASC,
priority: 3

,


In my controller, I have the init() method, which calls the service to gather the data from the backend and fills the selectOption array.



AutorizacoesReenvioService.listarTiposArquivoPorAno(moment().year()).then(
function (success)
var responseData = success.data;

responseData.forEach(function(item)
$scope.tiposArquivoGridSelectOptions.push(

value: item.id,
label: item.nomeArquivo

);
);

$scope.gridApi.core.refresh();
,
function (error)
console.error(success.data);

);









share|improve this question
























  • I tried using a plunker, but found no problems... There is no need to refresh the grid. Please check this plunker. The dropdown is toggled by pressing the 'toggle filtering' button.

    – Remko
    Mar 22 at 8:37












  • Thank you @Remko, but the problem is when I try to fill the dropdown options with data from backend using $http.

    – romeromedeiros
    Mar 22 at 12:41











  • That should not make any difference. Check the plunker again, I changed the toggleFiltering function (makes even less sense now ;), but it still works. Could you try and make a plunker showing the issue you are having, since I cannot reproduce your problem?

    – Remko
    Mar 22 at 15:26

















0















I've been struggling for more than 1 day trying to find a solution to pre-fill angular-ui-grid dropdown with data from the backend. And yes, I've seen many similar questions, but none of them talks about filling a selectOption with real data from backend.



It works fine with a pre-defined array like this: $scope.tiposArquivoSelecionados = [ value: 1, label: 'First', value: 2, label: 'Second', value: 3, label: 'Third'];



enter image description here



But when I try to fill the selectOption with data gathered from backend, the selectOption is not displayed. Take a look:



enter image description here



The data is gathered successfully, the grid is rendered successfully, what makes me think it's a timing problem.



Here is a list of a few workarounds I tried (all failed) to solve the possible timing problem:



  • refresh the grid after gathering the data;

  • put the columnDefs inside the service success callback

  • put a ng-if in the .html to display the grid only if the array.length > 0

None of them worked =/




selectOptions array declaration:



$scope.tiposArquivoGridSelectOptions = [];


Code from the GridOptions.columnDefs:




field: 'controleArquivoId',
name: 'Tipo de Arquivo',
cellClass: 'ui-grid-cell-padding',
enableFiltering: true,
enableSorting: true,
enableHiding: true,
filter:
type: uiGridConstants.filter.SELECT,
selectOptions: $scope.tiposArquivoGridSelectOptions,
,
sort:
direction: uiGridConstants.ASC,
priority: 3

,


In my controller, I have the init() method, which calls the service to gather the data from the backend and fills the selectOption array.



AutorizacoesReenvioService.listarTiposArquivoPorAno(moment().year()).then(
function (success)
var responseData = success.data;

responseData.forEach(function(item)
$scope.tiposArquivoGridSelectOptions.push(

value: item.id,
label: item.nomeArquivo

);
);

$scope.gridApi.core.refresh();
,
function (error)
console.error(success.data);

);









share|improve this question
























  • I tried using a plunker, but found no problems... There is no need to refresh the grid. Please check this plunker. The dropdown is toggled by pressing the 'toggle filtering' button.

    – Remko
    Mar 22 at 8:37












  • Thank you @Remko, but the problem is when I try to fill the dropdown options with data from backend using $http.

    – romeromedeiros
    Mar 22 at 12:41











  • That should not make any difference. Check the plunker again, I changed the toggleFiltering function (makes even less sense now ;), but it still works. Could you try and make a plunker showing the issue you are having, since I cannot reproduce your problem?

    – Remko
    Mar 22 at 15:26













0












0








0








I've been struggling for more than 1 day trying to find a solution to pre-fill angular-ui-grid dropdown with data from the backend. And yes, I've seen many similar questions, but none of them talks about filling a selectOption with real data from backend.



It works fine with a pre-defined array like this: $scope.tiposArquivoSelecionados = [ value: 1, label: 'First', value: 2, label: 'Second', value: 3, label: 'Third'];



enter image description here



But when I try to fill the selectOption with data gathered from backend, the selectOption is not displayed. Take a look:



enter image description here



The data is gathered successfully, the grid is rendered successfully, what makes me think it's a timing problem.



Here is a list of a few workarounds I tried (all failed) to solve the possible timing problem:



  • refresh the grid after gathering the data;

  • put the columnDefs inside the service success callback

  • put a ng-if in the .html to display the grid only if the array.length > 0

None of them worked =/




selectOptions array declaration:



$scope.tiposArquivoGridSelectOptions = [];


Code from the GridOptions.columnDefs:




field: 'controleArquivoId',
name: 'Tipo de Arquivo',
cellClass: 'ui-grid-cell-padding',
enableFiltering: true,
enableSorting: true,
enableHiding: true,
filter:
type: uiGridConstants.filter.SELECT,
selectOptions: $scope.tiposArquivoGridSelectOptions,
,
sort:
direction: uiGridConstants.ASC,
priority: 3

,


In my controller, I have the init() method, which calls the service to gather the data from the backend and fills the selectOption array.



AutorizacoesReenvioService.listarTiposArquivoPorAno(moment().year()).then(
function (success)
var responseData = success.data;

responseData.forEach(function(item)
$scope.tiposArquivoGridSelectOptions.push(

value: item.id,
label: item.nomeArquivo

);
);

$scope.gridApi.core.refresh();
,
function (error)
console.error(success.data);

);









share|improve this question
















I've been struggling for more than 1 day trying to find a solution to pre-fill angular-ui-grid dropdown with data from the backend. And yes, I've seen many similar questions, but none of them talks about filling a selectOption with real data from backend.



It works fine with a pre-defined array like this: $scope.tiposArquivoSelecionados = [ value: 1, label: 'First', value: 2, label: 'Second', value: 3, label: 'Third'];



enter image description here



But when I try to fill the selectOption with data gathered from backend, the selectOption is not displayed. Take a look:



enter image description here



The data is gathered successfully, the grid is rendered successfully, what makes me think it's a timing problem.



Here is a list of a few workarounds I tried (all failed) to solve the possible timing problem:



  • refresh the grid after gathering the data;

  • put the columnDefs inside the service success callback

  • put a ng-if in the .html to display the grid only if the array.length > 0

None of them worked =/




selectOptions array declaration:



$scope.tiposArquivoGridSelectOptions = [];


Code from the GridOptions.columnDefs:




field: 'controleArquivoId',
name: 'Tipo de Arquivo',
cellClass: 'ui-grid-cell-padding',
enableFiltering: true,
enableSorting: true,
enableHiding: true,
filter:
type: uiGridConstants.filter.SELECT,
selectOptions: $scope.tiposArquivoGridSelectOptions,
,
sort:
direction: uiGridConstants.ASC,
priority: 3

,


In my controller, I have the init() method, which calls the service to gather the data from the backend and fills the selectOption array.



AutorizacoesReenvioService.listarTiposArquivoPorAno(moment().year()).then(
function (success)
var responseData = success.data;

responseData.forEach(function(item)
$scope.tiposArquivoGridSelectOptions.push(

value: item.id,
label: item.nomeArquivo

);
);

$scope.gridApi.core.refresh();
,
function (error)
console.error(success.data);

);






angularjs angular-ui-grid ui-grid






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 0:50







romeromedeiros

















asked Mar 21 at 22:50









romeromedeirosromeromedeiros

508811




508811












  • I tried using a plunker, but found no problems... There is no need to refresh the grid. Please check this plunker. The dropdown is toggled by pressing the 'toggle filtering' button.

    – Remko
    Mar 22 at 8:37












  • Thank you @Remko, but the problem is when I try to fill the dropdown options with data from backend using $http.

    – romeromedeiros
    Mar 22 at 12:41











  • That should not make any difference. Check the plunker again, I changed the toggleFiltering function (makes even less sense now ;), but it still works. Could you try and make a plunker showing the issue you are having, since I cannot reproduce your problem?

    – Remko
    Mar 22 at 15:26

















  • I tried using a plunker, but found no problems... There is no need to refresh the grid. Please check this plunker. The dropdown is toggled by pressing the 'toggle filtering' button.

    – Remko
    Mar 22 at 8:37












  • Thank you @Remko, but the problem is when I try to fill the dropdown options with data from backend using $http.

    – romeromedeiros
    Mar 22 at 12:41











  • That should not make any difference. Check the plunker again, I changed the toggleFiltering function (makes even less sense now ;), but it still works. Could you try and make a plunker showing the issue you are having, since I cannot reproduce your problem?

    – Remko
    Mar 22 at 15:26
















I tried using a plunker, but found no problems... There is no need to refresh the grid. Please check this plunker. The dropdown is toggled by pressing the 'toggle filtering' button.

– Remko
Mar 22 at 8:37






I tried using a plunker, but found no problems... There is no need to refresh the grid. Please check this plunker. The dropdown is toggled by pressing the 'toggle filtering' button.

– Remko
Mar 22 at 8:37














Thank you @Remko, but the problem is when I try to fill the dropdown options with data from backend using $http.

– romeromedeiros
Mar 22 at 12:41





Thank you @Remko, but the problem is when I try to fill the dropdown options with data from backend using $http.

– romeromedeiros
Mar 22 at 12:41













That should not make any difference. Check the plunker again, I changed the toggleFiltering function (makes even less sense now ;), but it still works. Could you try and make a plunker showing the issue you are having, since I cannot reproduce your problem?

– Remko
Mar 22 at 15:26





That should not make any difference. Check the plunker again, I changed the toggleFiltering function (makes even less sense now ;), but it still works. Could you try and make a plunker showing the issue you are having, since I cannot reproduce your problem?

– Remko
Mar 22 at 15:26












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290394%2fangular-ui-grid-how-to-fill-a-dropdown-filter-with-real-data-from-database-back%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290394%2fangular-ui-grid-how-to-fill-a-dropdown-filter-with-real-data-from-database-back%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현