ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Set Dynamically the Title of the Columns on a Grid
Title:
B
I
{code}
?
I have a grid that comes from the database, but the title of the columns also need to come from the database (another query) Right now I am having in the HTMLHelper all the headers like: Header="str". For example: new Column { Bind = "ProductName", Width = 200, Header = "Product", CssClass = "productstyle" }, new Column { Bind = "Forecast", Width = 55, Header = "Feb-21", CssClass = "forecaststyle", ClientFormatFunc = "txt" }, new Column { Bind = "ForecastPlus1", Width = 55, Header = "Mar-21", CssClass = "forecaststyle", ClientFormatFunc = "txt" }, ... new Column { Bind = "ForecastPlus11", Width = 55, Header = "Jan-22", CssClass = "forecaststyle", ClientFormatFunc = "txt" }, But need the those Headers to be dynamic; The query is ready and the controller already has the details to place on each header title; but I don't know how to get the values to the grid as the controller is already returning the JSON for the grid which doesn't allow me to return anything else I hope this make sense
Save Changes
Cancel
AM
asked at 26 Feb 2021
are you able to render the titles in view ? (without using the grid) example: <p>title for ProductName: "db title value for ProductName"</p> do you need to changes these titles on each grid request (paging, sorting, grouping) or once the page is loaded the headers won't change ?
at 26 Feb 2021
Omu
I only need to set them on the page load, I Finally got it working by using ViewData as using a model didn't work Cool... new Column { Bind = "SalesMinus3", Width = 55, Header = ViewData["SalesMinus3Title"].ToString(), CssClass= "salesstyle" }, new Column { Bind = "SalesMinus2", Width = 55, Header = ViewData["SalesMinus2Title"].ToString(), CssClass = "salesstyle" },
at 27 Feb 2021
AM
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK