Example #1
0
        public string GetFormatter()
        {
            if (string.IsNullOrWhiteSpace(_clickFunction))
            {
                return(string.Empty);
            }

            string _clickHandler = string.Empty;

            if (_clickHandlerParams != null && _clickHandlerParams.Length > 0)
            {
                _clickHandler = string.Format("{0}(this,{1});", _clickFunction, string.Join(",", _clickHandlerParams.Select(x => string.Format(@"'""+ro[""{0}""]+""'", x))));
            }
            else
            {
                _clickHandler = string.Format("{0}(this);", _clickFunction);
            }

            return(string.Format(
                       @"function (cv,o,ro){{
    {1}
    var cf = ""\""{0}\"""";
    var ocl = ""onclick=""+cf+"" onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover') "";
    var str = ""<div title='"" + ""{3}"" + ""' style='float:left;cursor:pointer;' class='ui-pg-div ui-inline-edit' "" + ocl + ""><span class='ui-icon {4}'></span></div>"";
    return ""<div>"" + str + ""</div>"";
    {2}
}}", _clickHandler, _displayCondition == null ? "" : string.Format("if ({0}) {{\n", FilterConditionToStringConvertor.Convert(_displayCondition)),
                       _displayCondition == null ? "" :
                       @"}
return """";",
                       _toolTip, _iconClass));
        }
Example #2
0
        public void Convert_SimpleCondition()
        {
            string actual   = FilterConditionToStringConvertor.Convert(x => x["Status"] == "0");
            string expected = @"(ro[""Status""] == ""0"")";

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void Convert_FilterConditionString_CorrectJavaScriptObject()
        {
            string expected = @"ro[""ImageUrl""]";
            string actual   = FilterConditionToStringConvertor.Convert(x => x["ImageUrl"]);

            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public void Convert_ComplexCondition()
        {
            string actual   = FilterConditionToStringConvertor.Convert(x => x["Name"] == "JeyKip" && (x["Status"] == "0" || x["Status"] == "1"));
            string expected = @"((ro[""Name""] == ""JeyKip"") && ((ro[""Status""] == ""0"") || (ro[""Status""] == ""1"")))";

            Assert.AreEqual(expected, actual);
        }
Example #5
0
        public string GetDisplayCondition()
        {
            if (_displayWhenCondition == null)
            {
                return(string.Empty);
            }

            return(FilterConditionToStringConvertor.Convert(_displayWhenCondition));
        }
Example #6
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<img ");

            if (_imagePathColumnName != null)
            {
                sb.AppendFormat("src='\"+{0}+\"' ", FilterConditionToStringConvertor.Convert(_imagePathColumnName));
            }
            else if (!string.IsNullOrWhiteSpace(_imagePath))
            {
                sb.AppendFormat("src='{0}' ", _imagePath);
            }

            if (_toolTipColumnName != null)
            {
                sb.AppendFormat("title='\"+{0}+\"' ", FilterConditionToStringConvertor.Convert(_toolTipColumnName));
            }
            else if (!string.IsNullOrWhiteSpace(_toolTip))
            {
                sb.AppendFormat("title='{0}' ", _toolTip);
            }

            if (_width > 0)
            {
                sb.AppendFormat("width='{0}' ", _width);
            }

            if (_height > 0)
            {
                sb.AppendFormat("height='{0}' ", _height);
            }

            sb.Append("/>");
            return(sb.ToString());
        }