Solved

How to get the properties of a grid in another Razor view?

Posted on 2013-11-05
4
758 Views
Last Modified: 2013-11-13
Hi,

I have a partial view:
@{
    var grid = Html.DevExpress().GridView(settings =>
    {
        settings.Name = "GridView";
        settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartialSimaTabla" };

        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Home", Action = "GridViewPartialSimaTablaAddNew" };
        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Home", Action = "GridViewPartialSimaTablaUpdate" };
        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Home", Action = "GridViewPartialSimaTablaDelete" };
        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
        settings.SettingsBehavior.ConfirmDelete = true;

        settings.CommandColumn.Visible = true;
        settings.CommandColumn.NewButton.Visible = true;
        settings.CommandColumn.DeleteButton.Visible = true;
        settings.CommandColumn.EditButton.Visible = true;

        settings.KeyFieldName = "szam";

        settings.SettingsPager.Visible = true;
        settings.Settings.ShowGroupPanel = true;
        settings.Settings.ShowFilterRow = true;
        settings.SettingsBehavior.AllowSelectByRowClick = true;

        settings.Columns.Add("szam");
        
        settings.Columns.Add("szoveg");
    });
    if (ViewData["EditError"] != null)
    {
        grid.SetEditErrorText((string)ViewData["EditError"]);
    }
}
@grid.Bind(Model).GetHtml()

Open in new window


In the Index.cshtml I have a TreeViewMenu which has an onclick:

    function TreeViewMenu_OnNodeClick(s, e) {
      
        alert(s.name + ' ' + e.node.text + ':' + e.node.name + '_');      

    }

Open in new window


How can I change let's say the caption of the grid's first column depending on the node?
I don't know even how to refer to the grid in this section.

Thank you
0
Comment
Question by:starhu
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Are you asking how to refer to a DOM element within the JavaScript code?
0
 

Author Comment

by:starhu
Comment Utility
If the grid is a Dom element, the yes.

(I'm a beginner in asp.net, sorry)
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
You will most likely be using document.getElementById to get a reference to the element.  It all depends on how the HTML is generated for the rendered page.  If your element is not assigned a unique ID, then it gets more complicated.
0
 

Author Closing Comment

by:starhu
Comment Utility
I got a more precise answer with example from another forum
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now