Author Topic: Dynamic Column Binding From JSON  (Read 3999 times)

mercury85

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 58
  • ASP.NET, VB.NET, MVC, JS, C#, VBA, SQL, MDX, DAX
    • View Profile
Dynamic Column Binding From JSON
« on: April 21, 2018, 11:39:22 am »
I was curious, I tried making columns dynamic defined in a JSON... Is it possible to get get columns like:

  var colM = {
        location: "remote",
        recIndx: "dcol",
        dataType: "JSON",
        method: "GET",
        url: "/Content/collcolmodel.json",
    };

dcol is where the colM model is nested, or can I just call "title":"" if this is possible?

I want to have the ability to store different definitions of the object model and just call from REST.

mercury85

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 58
  • ASP.NET, VB.NET, MVC, JS, C#, VBA, SQL, MDX, DAX
    • View Profile
Re: Dynamic Column Binding From JSON
« Reply #1 on: April 24, 2018, 12:36:46 am »
Ok, maybe I am trying to accomplish too much at one step,  I have been reading thru everything and I am thinking may just have a structured source table of x and just do dynamic titles based on the requirement in an array....

I was wanting to store the colM string then just do a pull by having some column flag of 1 or 0... Reviewing documentation we can do a tableToArray( $table ), but I don't want all the items from the data to be in the column model, the other columns on the source will identify format, edit fields, other parameters, etc...

Just curious if the flexibility is there, or am I to go on a set structure that I am thinking, then we do an array of objects for data, or do we do array of array then make an array for the title.

IE:
    var ttlIndx = ['Col1', 'Col2', 'Col3', 'Col4', 'Col5'];
    var editIndx = [false, false, true, true, true]

    var colM = [{title: ttlIndx[0], editable: editIndx[0], dataIndx:  ttlIndx[0],  ...}

Either way any property I can call from a REST and the var = Rest call from Ajax.  Just trying to avoid a static approach on this..

Thoughts if this would be the correct approach.  Please and thank you!!!
« Last Edit: April 24, 2018, 01:45:34 am by mgregory85 »

mercury85

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 58
  • ASP.NET, VB.NET, MVC, JS, C#, VBA, SQL, MDX, DAX
    • View Profile
Re: Dynamic Column Binding From JSON
« Reply #2 on: April 25, 2018, 08:14:28 am »
I figure I will reply to my own questions as it may help others.

I am trying to improve the flexibility and figured I would share. 

Here is my take on my posted question on bringing in the object properties using an array of objects, sat there for a bit until I realized I needed to set async to false, and not bring the string in, but the objects...

I am building on top of existing examples from our administrator, thanks for providing the barebones ParamQuery!!

http://jsfiddle.net/mgregoryibp/ntfn3q9h/

mercury85

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 58
  • ASP.NET, VB.NET, MVC, JS, C#, VBA, SQL, MDX, DAX
    • View Profile
Re: Dynamic Column Binding From JSON
« Reply #3 on: April 26, 2018, 09:10:08 am »
http://jsfiddle.net/mgregory85/ntfn3q9h/

Wrong URL and strange I couldn't modify it.

Cheers.