Title: Datagrid - Dynamic column Post by: firob on April 01, 2020, 08:00:46 PM Hi,
I'm trying to change dynamicly the columns of a datagrid with javascript. I get the following information from a php script that go in a database to get the information, then returning it to a json format with the information of the field, title and width. This code is in a function that is called when I change a parameter in a droplist, so the column adapt to that parameter. The problem is, the header name of the column, or the width, doesn't work. Here a picture of what I see : https://i.stack.imgur.com/58UEv.png I see the column changing, when I change the parameter on the droplist menu, so that part is working. If I manually write the same parameters, it all works. But not when I try to generate it with my code. So here the code : Code:
You can see on my picture the array that is generated in the console... If I do that same thing, but writing it myself : Code: var testrow = {field:"Dateheure",title:"Date",width:150}; I also noticed that if I try to compare that "testrow" that I write manually with my "row" that I generate with the code, with the same exact parameter list, using this : Code: console.log(row===testrow); What am I doing wrong? How can I generate with javascript an array that will work to insert into the datagrid? Thanks if you can help me Title: Re: Datagrid - Dynamic column Post by: jarry on April 01, 2020, 11:21:37 PM Please try this code instead.
Code: var dg_grid = new Array(); Title: Re: Datagrid - Dynamic column Post by: firob on April 01, 2020, 11:35:25 PM Oh !! It's working now ! Wow thank you so much, I just spent hours trying to figure this out.
|