sonata_type_collection set default number of rows on page load - sonata-admin

I make use of the sonata_type_collection for order rows inside my order. As soon as I create a new order I can click a button to add an order row.
Is it possible to change it to automatically show 5 rows on page load instead of clicking the button for the first row and so on?
I guess it is possible to make a JavaScript script for on page load to 'click' the Add New row button 5 times.

Well you have several options how to accomplish this.
Override create or update method in CRUDController and if order does not have rows just create them and add to Order, they will be rendered.
In method getOrderRows you can return 5new rows if non exits.
If you first persit order you can also add rows in prePersist method in admin

Related

Material-Table replace checkboxes with radio buttons

I'm using material-table to show some data, now I want to select one row at the time to pass the row's data to another component, so being able to select multiple rows at the time isn't what I'm looking for and the main suggestion is to go for a radio button. So is there a way to replace the checkbox on the table with radio buttons or make the selection option to only allow one row to be selected at the time?
According to documentation your hands are tied. But, this might work:
Add selectedRow key to the component which uses MaterialTable
Create some method or function e.g. handleSelection and pass it to onSelectionChange prop. Argument to this func is an array which handleSelection returns
When user select some row, set selectedRow to that row object
If user click on "slelect all" checkbox (top left) - show notification that action is not supported. If there is no way to unselect all checkboxes programatically - unmount and than mount MaterialTable (to reset checkboxes)
If one row is already selected, than another one get selected (which makes two selected rows) - repeat step "4"
I know this is a bit complicated, but it's a best I could think of at the moment
n.b. Another thing you can do (to force users to select only one row) is to hide table on multiple selection and show message about what they can do. Message could be closable. When message get closed fresh table could appear (mount aggain).
Update
Just have found another option that might work for you. Take a look at this page at the "Simple Action Example". There you have buttons instead of checkboxes. I am starting to think that:
options={{
selection: true
}}
is not the right option for you.

Add/ Update / delete over large collection in angular application performance issue

I have a angular page which shows 1000 of nested record (parent- child up to n-level) and further user can add/edit/delete the record from UI at any location. Each row contains a button to add row above/below, based on that new row is created. This UI has also drag and drop functionality over each row so if any row is draged over another then parent child rows created. For this we have a json collection in nested way and in UI we have created a directive which is called recursively to show the nested record using ng-repeat.
We are facing performance issue here, if user try to add a new row at any specific point we are adding a new blank row in json data on specified index and based on this blank row a blank form is shown which renders very slowly.
Functionality is working but whenever a new add/update/deleted happens over row then it stuck and takes time to re-render the UI.
I cannot implement pagination here to restrict rows as user can create parent child relation by dragging over any row so all record should be shown.
Any one can suggest if other way around for this performance issue?

Select Unselect logic in Salesforce

I have a requirement, where there is a checkbox on UI when I select it the first time it gets selected when I click it again it is deselected.
So in logic, I am adding the selected parameter to a set, and if it is already present I remove it for deselecting the parameter.
But this approach is not working when I have to count how many I have total, it gives incorrect values.
I have to implement select multiple and deselect multiple in a web page. Can anyone help me with this
Do you have a wrapper? Have a select all/deselect all command link, that command link will call an action which will select/deselect all of the records, then just rerender the table..

Grid not updating upon change in model in angularjs

Folks,
I am using ng-grid to display a list of items.
I want to give my users ability to rearrange the rows in the list.
i.e move the rows up and down as they please.
Now,
However when I update the grid data in the backend i.e say change the index of a particular row, that row does not automatically change locations in the front-end.
What am i missing here ?
I have created a plunker to describe the problem
http://plnkr.co/edit/s1hrTSqF2zeZo3Btaln0
The grid doesn't use the index of the array to order it, so even if you are changing it, because the data is still there nothing happens.
What you could do is define an order field and update the value then changing the values as shown in this plukr. The order field you can hide it from the grid if required using columnDefs to explicitly defined which column should be shown.
Regards

EXT JS Row Expander in Salesforce

Folks,
I am trying to display EXT JS with Row Expander plugin in a Visual Force page.
Check this link http://mikhailstadnik.com/ext/examples/nested-grid.htm
As per the link, I am successful in displaying Accounts in first grid and respective Contacts in child grid.
Problem is: When I click on first row, it is expanded and shows the respective contacts.
When I click on second row and first row is not closed, the data which I can see for second row (Contacts) are visible at first row contacts also.
So, I think when second row is clicked, I need to close the first row.
Please suggest me how to do this..
The plugin you are talking about features collapseRow(row) method.
Each time you are trying to expand a row (use beforeexpand event for that) you need to loop through all the rows and collapse expanded ones.
Here is how you check if the row is expanded:
Ext.fly(row).hasClass(this.rowCollapsedClass) // this is referring to plugin instance

Resources