dynamic-table | Dynamic HTML grid with jQuery/AngularJS frontend | Grid library
kandi X-RAY | dynamic-table Summary
kandi X-RAY | dynamic-table Summary
(Abandoned) Dynamic HTML grid for PHP and NodeJS.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dynamic-table
dynamic-table Key Features
dynamic-table Examples and Code Snippets
Community Discussions
Trending Discussions on dynamic-table
QUESTION
As mentioned below by Aaron, the "Other Option" approach works without issues and feels a lot cleaner. I'll leave the updates and everything in case anyone in the future has a similar problem and the workarounds provide useful somehow.
I'm having a weird problem trying to render dynamic components inside an Angular material table with pagination and sort.
Here is a Stackblitz with the reproduced issue. From what I've researched, it seems to be some sort of change detection issue, although I could be wrong on that since I have no idea why it's happening. If anyone has any ideas on how to fix this issue, or if I'm doing something blatantly wrong, feedback and help would be highly appreciated.
Current Behavior:I'm using @ViewChildren and ComponentFactoryResolver inside a material design table to render components dynamically with a few pages of data. Everything looks fine, however when using matSort to sort the data, some of the rows that have dynamic components show the wrong data values, while the rest of the row (non-dynamic) has the correct ones. See screenshots below:
Before sorting:
After sorting:
console log of component instances (note the correct status field is passed, yet the wrong one is rendered).
Expected Behavior:Data and rendered components are shown accurately when I sort. Should match the dataSource.data field.
Minimal Reproduction of the Problem with Instructions:Visit the Stackblitz and run the application. Click the sort header for "Order Status". Notice how the first entry in the table says "Delivered" while the actual dataSource has it as "Cancelled. Also not that the rest of the row is accurate - just the dynamically rendered component is incorrect.
What I've Tried:Tried setting the status with a get() and set() instead of an @Input() and register an ngOnChage, where I call a changeDetectorRef from the component itself, but the issue persisted.
Tried changing the ChangeDetectionStrategy - neither one did anything.
Tried the solutions in the below section as well
This seems to be the same issue, however it was never answered. I'm hoping providing a Stackblitz will be helpful in getting the same answer. It seems to be some sort of change detection issue according to the poster.
When loading same component with different data, old data still showing - Angular 5
Tried explicitly calling the detectChanges() and markForCheck() chanceDetectionRef methods for the componentRefs, the parent component, the actual component that gets dynamically created with no luck.
Angular dynamic component loader change detection issue
Change detection not working when creating a component via ComponentFactoryResolver
Possible Workaround / More Weird Behavior:If you sort by Order Status and get the wrong value to be in the first row as before, and then paginate to the next page and back, component shows the correct value. I'm assuming the pagination forces some sort of change detection in the material table, or the templates, or something along those lines, but I have no idea why the sort wouldn't do that. The current work around I have going is to just paginate to the next page and back, however that is by no means an acceptable solution, and I'd really like to understand what I'm doing wrong here, or what a fix for this is.
Update 1As per Aaron's additional insight below, I've added an Updated Stackblitz with a far more simplified example. On a closer look through, pagination doesn't seem to play a factor into the weird behavior. I can reproduce the issue with just 2 table entries and a sort (all pagination code removed). I've changed up the data coming in to match across the rows so it's clearer which rows come from where.
Here's a combined screenshot of before and after sorting with 2, 3, and 4, records:
I'm currently trying to see if I can force the table to re-render (assuming it's possibly shifting things around), and eventually going to dig through the source code for the table.
Update 2One workaround I was able to figure out is to set my dataSource to an empty array after I've saved a copy of it with the splice()
in the onSortChange()
right before doing my filtering logic, then setting it back to the filtered array. I'm assuming that triggers some sort of update in the material datasource/table which forces a re-render or update. I'll keep trying to figure out if there's a better approach to this, since it seems weird to be doing that, and in my original application I have a filterPredicate which also causes the same issue when filtering/resetting the filter.
Aaaaaand finally after some more research on this, I've come to at least somewhat of a solution that makes sense. After what I said on Update #2, I found this post:
https://github.com/angular/components/issues/15972#issuecomment-490235603
which explains why the table wasn't getting the updated dataSource. In my case it was probably a lot harder to figure that out since I was doing a sort/filter, and didn't think it would be directly tied to that. I'll still explore a few more ideas in the next few days, but if neither work, I'll go ahead and mark this as solved after that.
...ANSWER
Answered 2021-Mar-18 at 01:51I'm not 100% what is going on, but playing around with it a bit, I don't think the issue is change detection. I started by commenting out everything after the
cellTemplateRef.clear();
in createDynamicComponents()
in the dynamic-table.components.ts
Doing this, definitely would see everything in that column disappear.
Then taking the other approach of only commenting out the
cellTemplateRef.clear()
, you'll see your new components get shoved in on top of the old one.
Next step was the remove the old component after you added the new one...
After the Object.keys.... loop:
QUESTION
I have a list of rooms, times and students.
...ANSWER
Answered 2021-Mar-05 at 07:06You can try something like this:
QUESTION
i found a script that creates a table of content for sharepoint sites. It works fine, but at our sharepoint sites the first headline (H1) is the page title. So i have to skip the first Headline (Page title).
Does anybody know which part i have to edit to fit the skript for my needs? =)
...ANSWER
Answered 2021-Jan-05 at 15:57Inside of your for loop that begins with
for (var i = 0; i < obj.length; i++) {
You can put on the first line of the loop (before If tag is a title tag)
if (i === 0) continue;
QUESTION
I have an angular material table which I need to generate some somewhat repetitive columns for. So I made a component that generates the repeating columns and attempted to inject it into my mat-table
, but it does not appear to work. Am I missing something obvious? I've built tables with dynamically named columns before but I did it within the same component as the table itself, so I'm thinking it's an issue of being contained within another element or something.
I believe this is possible, just can't find the right terms to google. Tried to make the example as simple as I could. The 'property' attribute on the repetitive-columns
component helps to dynamically generate unique column names to feed back to the displayedColumns
property for the mat-table
The displayedColumns
value gets updated naively in this example and generates a ExpressionChangedAfterItHasBeenCheckedError, but appears to me like it should work otherwise:
Table Template
...ANSWER
Answered 2020-Nov-12 at 14:44OK, I figured this out finally.
Found this question: Angular Material mat-table define reusable column in component
which led me here: https://github.com/angular/components/issues/13808
In short, you have to manually tell the table about the column definitions. This is accomplished by injecting a reference to the MatTable into your child component.
So the constructor for the 'my-repetitive-columns' looks like:
QUESTION
hello I have a question following the advice of you Razor View dynamic table rows, I made my table with foreach but not and could manage to make you create new columns, if I add a record is put in the same column, does not make a jump for another column, What can I do in this case? So I have my view on razor
...ANSWER
Answered 2020-Aug-13 at 10:11I have a bit of difficulty understanding your question; I am sure you are doing your best to explain your problem. So excuse me if this does not answer your question.
I think I see what you are trying to do there; placing 3 blocks in a row then followed by 3 other blocks.
One of the problems I foresee is that when you have exactly %3
items (so you have for instance 6 items), the last one will add a to your html and then the loop will end and add one more . So rather than checking %3
you should also check if you aren't at the last item; So something like this
QUESTION
Have you encountered a problem when you route to component and loading a table. But table is empty without data.
I mean the component / table is displayed. Data as i can see are in state(seassion storage] and loaded. I am able to display them if i refresh the page.
By the way i could dispatch state before this component and my problem could be solved or use simple service with call on api. But this is not solution for me.
So my problem is = how could i display / load data before view?
My assets.state.ts
...ANSWER
Answered 2020-Aug-04 at 08:50Most likely your data is not loaded yet when you call selectSnapshot
. You are way better of using a @Select
statement:
QUESTION
I'm trying to simplify this one page and so I have a new component Table.tsx
which does what it seems to do, render the head and rows of a table! HOWEVER, the rows aren't rendering in this case and it's tripping me out. Could it be me calling return for the rows a little before for coinss
or sparkline
to be defined?
ANSWER
Answered 2020-Aug-11 at 23:01Try using state.
let [rows, setRows] = useState(null);
Once your rows data is ready. Call setRows(rows)
so that your component
knows to update. Currently your rows data is set after your component is rendered.
Use the following logic. (I had remove the util function since I didn't have it. You can add it and run.)
QUESTION
What I find most interesting is that {users.username}
works, same with {users.profile.avatar}
and even {users.profile.bio}
but not what I need most of all: {users.emails.verified}
and {users.emails.address}
I'm guessing that it has to do with the mapping of the data? Perhaps it's how I'm trying to call it? I tried {users['emails']['address']}
as well.. but it doesn't work either. yet it works for {users['profile']['bio']}
which makes it a bit bigger of a headache for me. Any help would be awesome, I'm all ears as to learning how to go about this!
ANSWER
Answered 2020-Jul-22 at 18:49Well, I guess I could mark this question answered!
Another reason to define my types properly:
Ah! Just noticed the console log in the image. emails seems to be an array of email objects and not an object, so instead of {user.emails.verified} you should have {user.emails[0].verified}, same goes for address. Also, you may want to check if emails actually contains something and/or if it contains more than one email object – ibrahim mahrir
So for my specific use case: {user.emails[0].address}
was what I was looking for as well as {String(user.emails[0].verified)}
for returning boolean values!
QUESTION
Ive got a where I've implemented an
addRow()
function that creates a new row in the table using a set of default values based on the data-type.
The issue that I'm having is that everytime I create a new row, I need to re-assign the MatTableDataSource
, the MatPaginator
, and the MatSort
. If I don't perform the reassignments, then the new data doesn't show, or the pagination/sorting does not work.
All these reassignments seem expensive and roundabout, especially on larger datasets, but I'm not entirely sure how to do it better.
dynamic-table.component.ts
...ANSWER
Answered 2020-Jul-22 at 15:33You can use setters for pagination and sort components
QUESTION
ANSWER
Answered 2020-Jul-16 at 15:46Looks like your table is not part of the component where you want to style it.
Did you try with ::ng-deep
?
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dynamic-table
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page