Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arun 136 posts 369 karma points
    Sep 14, 2020 @ 14:24
    Arun
    0

    Index number of Grid Content in DTGE Grid

    Is there any way to get what is the position of a grid element being used in it's view?

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Sep 14, 2020 @ 20:01
    Marc Goodson
    100

    Hi Arun

    I'm wondering if you update your Grid Renderer file in /views/partials/grid/

    Bootstrap3-Fluid.cshtml (or Boostrap3.cshtml or similar if you are using a custom one).

    And update the bit that renders the particular editor:

    <div @RenderElementAttributes(area)>
                        @{ int gridIndex = 0; }
                        @foreach (var control in area.controls)
                        {
                            if (control != null && control.editor != null && control.editor.view != null)
                            {
                                <text>@Html.Partial("grid/editors/base", (object)control, new ViewDataDictionary { { "gridCol", area.grid }, { "gridIndex", gridIndex } })</text>
                            }
                            gridIndex++;
                        }
                    </div>
    

    To pass through the current index (and grid cell number if that's useful to know too), through to the particular editor via the MVC ViewBag...

    Then in your editor partial view in /views/partials/grid/editors

    you could read the values from the ViewBag like so:

     int gridCellCol = 0;
        Int32.TryParse(ViewData["gridCol"].ToString(), out gridCellCol);
        int gridEditorIndex = 0;
        Int32.TryParse(ViewData["gridIndex"].ToString(), out gridEditorIndex);
    

    and then you'd have the context of what position the 'editor' was used in and the index number...

    ... is that what you are after?

    regards

    Marc

  • Arun 136 posts 369 karma points
    Sep 15, 2020 @ 05:49
    Arun
    0

    Thanks Marc
    This is what I was looking for :)
    Thank you for giving the solution.
    -Arun

Please Sign in or register to post replies

Write your reply to:

Draft