Exemplo n.º 1
0
        public string GetHtmlModelString <T>()
        {
            DataConfigureAttribute attribute     = DataConfigureAttribute.GetAttribute <T>();
            StringBuilder          columnBuilder = new StringBuilder();

            if (attribute != null)
            {
                attribute.InitDisplayName();
                foreach (var item in attribute.GetViewPortDescriptors(true))
                {
                    columnBuilder.Append(GetHtmlModelString(item, item.DataType.Name));
                }
            }
            else
            {
                Type           tType     = typeof(T);
                PropertyInfo[] propertys = tType.GetProperties();
                foreach (var item in propertys)
                {
                    string typeName = item.PropertyType.IsGenericType ? item.PropertyType.GetGenericArguments()[0].Name : item.PropertyType.Name;
                    columnBuilder.AppendFormat("{0}:{{ Name: '{0}',DisplayName:'{0}',Width:150,DataType:'{1}',DateFormat:'',JsDateFormat:'',ValueDateFormat:'',Hidden:0 }},", item.Name, typeName);
                }
            }
            return(string.Format("{{{0}}}", columnBuilder.ToString().Trim(',')));
        }