jQWidgets Forums

jQuery UI Widgets Forums Grid Column names dynamically json

This topic contains 3 replies, has 2 voices, and was last updated by  ScottNL 13 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Column names dynamically json #4471

    ScottNL
    Member

    Grid pro’s,

    How do i load these setting dynamically

    $("#jqxgrid").jqxGrid(
    {
    width: 800,
    source: dataAdapter,
    theme: "classic",
    columnsresize: true,
    columns: [
    { text: 'id', datafield: 'menu_id', width: 80 },
    { text: 'Beverage Type', datafield: 'parent_id', width: 120 },
    { text: 'Calories', datafield: 'name', width: 120 },
    { text: 'Total Fat', datafield: 'url', width: 120 },
    { text: 'Protein', datafield: 'page_order', minwidth: 120 }
    ]
    });

    The most important part is the columns.
    if you have a few hundred tables with different languages you would want this to be included in the json call

    any ideas? thanks in advance

    Column names dynamically json #4474

    Peter Stoev
    Keymaster

    Hi ScrottNL,

    To change the columns Header Text displayed to the users, you can use this:

    $("#jqxgrid").jqxGrid('setcolumnproperty', 'firstname', 'text', 'New Text');

    – ‘firstname’ is the datafield’s name.
    – ‘text’ – this is the property name
    – ‘New Text’ – this is the new value of the ‘text’ property.

    To change the entire Columns Array, you can dynamically set the Grid’s columns property.

    For example:

    var columns = [{ text: 'Column 1', datafield: 'firstname', width: 90 },
    { text: 'Column 2', datafield: 'lastname', width: 90 },
    { text: 'Column 3', datafield: 'productname', width: 150}];
    $("#jqxgrid").jqxGrid('columns', columns);

    Note that the Grid should be initialized when you change any of its properties or call a method i.e the data binding operation should be completed.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Column names dynamically json #4478

    ScottNL
    Member

    Good stuff Peter,

    Exactly the answer i was looking for.

    Column names dynamically json #4479

    ScottNL
    Member

    1 more question Peter.

    Where do i find these settings

    cellsalign: ‘right’, cellsformat: ‘c2’

    found in { text: ‘Total’, datafield: ‘total’, width: 100, cellsalign: ‘right’, cellsformat: ‘c2’ }

    I looked at the documentation and api reference but could not find them.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.