Dynamically populate angularjs-dropdown-multiselect with array of objects from mysql database - angularjs

I'm using the angularjs-dropdown-multiselect.js to create a multi-select drop-down. I'm trying to dynamically populate the drop-down with existing data from mysql database. If I hardcode the array of objects in my scope, the drop-down is populated correctly and the glyphicon checks are highlighted, as being checked, and the correct numbers are selected. If I pass in the array of objects from the database, as a variable to the scope, the glyphicon checks are not highlighted next to the selected choices, but the correct number of selected is correct. Any ideas on how to fix this? Here is a link to the code I'm using: http://dotansimha.github.io/angularjs-dropdown-multiselect/#/.

In the backend, wherever you perform the query to get the array of items from the database, try making a loop that will go through the returned items, and push them into an array, one by one.
then make a get call that will receive array as a response from the database.
I hope this is what you work looking for!

Related

How to persist selection on React using mui-datatable

I'm using mui-datatable to implement table in my app. I've every feature I need up and running, and I'm using server side data and pagination.
The problem is that I need to persist selection of rows when the user change the current page.
I can store the ids of the rows that where selected in an external array using onRowSelected.. but I'm not sure how to make the table render those rows as selected when user changes the page.
Bare in mind i'm using server side data, so the idea would be that in page 1, when I select row 1, a take the id of that record and add it to the array of selected ids. Then I need to check if the ids of rows that are currently displayed in the page are included in the selected array, and if so then check it as selected in the table. That way when I change the page, the same logic would run and all rows would be cleared since none of the row in the new page are selected.. I think you get the point.
I dont know where should i check if the row's id is included y my selected array and if so, how to check it in the datatable.
Thanks in advance for the help.
You can wrap your entire MUI datatable in another component which maintains the state of all selected rows
I'm stupid... I just needed some sleep xD
My problem was solved once I realized that I just needed to pass the rowsSelected option like this:
rowsSelected: this.state.pictures.filter(p=>this.state.selectedIds.includes(p.id)).map((p,i)=>i)
where this.state.picture will change when the user changes the page and rowsSelected will also changed.
Never mind... It's a rookie mistake.

Backgrid.js: Getting selectedmodels() attributes

I am trying to add a shortlist button to a datagrid (using backgrid.js http://backgridjs.com/)
What i want is the shortlist button takes the id's of all selectedmodels and save them in database.
If i do this this.model.get('id') it takes the id of current row but i want to take the id's of checked check-box's.
When I look closer and use "grid.getSelectedModels", this call returns an empty array.
So how can i get the id's of selectedmodels?
The only way grid#getSelectedModels is empty is when you are not using SelectAllHeaderCell in combination with SelectRowCell. Is this the case?

AngularJS - After Filtering The Model Isn't Updated

I just wanted to see if anyone has had experience with the issue I having. I am currently populating a select element from a restful web service using the ng-options feature and assigning it to my model with ng-model. I have also applied a filter to this select that changes the list based on the value from another select element. Everything works as intended from the display side. If I change the master select element and it filters the second select to not include the currently selected item, the display shows correctly and displays 'please select'. So this looks great and works as I intended but when this scenario happens the underlying model isn't updated and still has the invalid option stored in it. If I pass the model back to the server for further processing, I am getting values that might not be valid.
Does anyone have any ideas on how to have selected that filter one another also update the underlying model ?
I appreciate any ideas.

Ext JS ComboBox Dynamic Behaviour

I am trying to load/show completely different set of values in a combobox(this one resides as a editor within an EditorGridPanel) based on the valueField of another combobox(this one resides outside the grid in top bar). I have already seen a tutorial(http://www.extjs.com/learn/Tutorial%3ALinked%5FCombos%5FTutorial%5Ffor%5FExt%5F2) wherein ALL the values for the secondary object are stored locally and then filtered however, I have already created a link which will supply me with json data based on the valuefield, so I would like to use this url to keep the code efficient.
I have also tried to refresh the datastore but its simply not being reflected on the combobox.
Please advise
Thanks
Found the solution, loading values from a url is straightforward.. if you want to manipulate the query(like I wanted), you would have to strip url off the dynamic parameters and assign them to baseParams of the store and then call store.load()
It worked for me!!

ExtJS loop through form fields that got a specified name

I'm using ExtJS 3. I have a formPanel with many "cloned" fields and I gave every field the name "price[]". After submit I would like to loop through every field that has the name "price[]" and get their values one at a time to be checked against something in the database.
Note: there are other fields in this form so that's why I need to specify witch items to get from it, by name. I know how to submit the form, I just need to loop through those field and get their values.
How can I do this ?
Thank you!
You can use the find(propName, value) method of FormPanel. It returns an array of all the matches. The matches will be Ext.form.WhateverField objects, depending on what types of input elements your form has, and not raw DOM elements.
var priceFields = myFormPanel.find('name', 'price[]');
The BasicForm object has a property items: it is a mixed collection. You may iterate over the collection.
ExtJS forum

Resources