Hello, in my solution for a given table I have a HiddenFields string field which contains the comma separated list of fields that I want to hide from LIST, VIEW, ADD and EDIT pages.
For example for customers table (CustomerID,FirstName,LastName,CustomerLevelID,NickName,...) if I have the HiddenFields = "CustomerLevelID,NickName" I have to set CustomerLevelID.Visible and NickName.Visible to false.
I want to iterate the comma separated list and extract the field names: from the string field name (e.g. myFieldName="CustomerLevelID") how can I set the Visible property to false? something like CurrentTable.Field[myFieldName].Visible=false.
Thanx.
Hide some fields from LIST,ADD,VIEW and EDIT pages from a comma separated string
-
- User
- Posts: 111
Hide some fields from LIST,ADD,VIEW and EDIT pages from a comma separated string
-
- User
- Posts: 111
Perfect it works, thank you.
Now I have this code in Page_DataRendering event for EVERY TABLE I need.
I tried to put the code in a GLOBAL FUNCTION, but it gives me the error that FieldByName is not available there.
How can I run this code from every table without coding all the specific events? Can I put some code in a TABLE GENERIC Page_DataRendering call?
// Page Data Rendering event
public void Page_DataRendering(ref string header) {
// Example:
//header = "your header";
//this is my full code
string jsonStr = Profile.GetValue("myJsonConfig");
JObject jsonObj = JObject.Parse(jsonStr);
var items = jsonObj["tables"][CurrentTable.Name]["fieldstohide"].ToString().Split(new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
foreach (string item in items) {
var myfield = FieldByName(item);
myfield.Visible = false;
}
//I would like to simply call the global function SETFIELDSVISIBLE()
}