Copied to clipboard

Flag this post as spam?

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


  • Arun 79 posts 219 karma points
    16 days ago
    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 1247 posts 8423 karma points MVP 5x c-trib
    16 days ago
    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 79 posts 219 karma points
    16 days ago
    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