Backgrid.js: Getting selectedmodels() attributes - backbone.js

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?

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.

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

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!

Angular multiple Post and Put request at same time using $q

I want to create dynamic configuration where we need create(post) the record if not already created if it's created need to pass put request for that. In each accordion group there is form but we have only save button to save all.
When clicking on the save button, have it aggregate all the records and determine which ones are new and which are existing. Once you have all the records with their statuses, loop through each of the records and do POST and PUT based on their status.

How do i get my id field to show up in the request data when updating multiple records?

Datasource: Array source (Open source code)
I have a __getTable method that loads the data from a configuration file to an array that looks like this:
I created a method that takes in data in this form and creates a table out of it. The table creates a column in the row for every field present in the given data array except for id. id is a hidden field and the code generated by the input function looks like this:
but shows up like this when inspecting the code in firebug:
Ignore all except for what is in the control-group division.
Since im using the array source, i create my own update method and have to call updateAll() in my controller to call the method. All the data i need is in the request data except for the id! why, and how can i fix this? It looks like this:
The rest of the information on here might not be necessary but ill post it just in case.
I found the problem. Most of it was unique to my code though. There was a bug where i call the $this->Widget->input function. I use index rather than the id and that screws up my tabs. each data array passed in to the function had indexs from 0-~11 and so the values were overriding each other since the submit was for multiple tabs. Also i have a function 'open' that opens a table and the rows were specified to have 4 columns rather than 5 and id was the 5th column.

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