93 lines
3.6 KiB
C#
93 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Web.Mvc;
|
|
using System.Web.Mvc.Html;
|
|
using Kreta.Framework;
|
|
|
|
namespace Kreta.Web.Helpers
|
|
{
|
|
public static class SearchPanelExtensions
|
|
{
|
|
public static SearchPanelHelper SearchPanel(this HtmlHelper helper, string formId, string gridId, int columnNumber = 1, bool autoOpen = false, string actionName = "ReloadGrid", Dictionary<string, object> htmlAttributes = null)
|
|
{
|
|
if (htmlAttributes == null)
|
|
{
|
|
htmlAttributes = new Dictionary<string, object>();
|
|
htmlAttributes.Add("id", formId);
|
|
htmlAttributes.Add("columnNumber", columnNumber);
|
|
}
|
|
|
|
string btnValue = StringResourcesUtil.GetString(238);
|
|
string btnId = formId + "Btn";
|
|
helper.SearchPanelStart(autoOpen);
|
|
|
|
var mvcForm = helper.BeginForm(null, null, FormMethod.Get, htmlAttributes);
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
sb
|
|
.Append("<script>setTimeout(function() {")
|
|
|
|
/*SearchPanel oszlopossá tétele*/
|
|
.Append("var column = $(\"#").Append(formId).Append("\").attr(\"columnnumber\"); var cnt = 0;")
|
|
.Append("$(\".searchInputRowHeight\").each(function() {")
|
|
.Append("cnt = cnt + 1;")
|
|
.Append("if (column == cnt) {")
|
|
.Append("$('<br />').insertAfter($(this));")
|
|
.Append("cnt = 0;} });")
|
|
|
|
/*SearchPanel KendoPanelBar legyen*/
|
|
.Append("$(\"#searchPanelUl\").kendoPanelBar({ expandMode: \"multiple\" });")
|
|
|
|
/*Listázás gomb felrakása*/
|
|
.Append("$(\"#").Append(formId)
|
|
.Append("\").append('</ br><input type=\"button\" class=\"k-button k-button-icontext\" id=\"").Append(btnId).Append("\" value=\"").Append(btnValue).Append("\" />\');")
|
|
|
|
/*Listázás gomb click function*/
|
|
.Append("$(\"#").Append(btnId).Append("\").click(function() {")
|
|
.Append("KretaGridHelper.refreshGridSearchPanel(\"").Append(gridId).Append("\",\"").Append(formId).Append("\")")
|
|
.Append("});")
|
|
|
|
.Append("},1);</script>");
|
|
|
|
helper.ViewContext.Writer.Write(sb.ToString());
|
|
return new SearchPanelHelper(helper);
|
|
}
|
|
|
|
public static void SearchPanelStart(this HtmlHelper html, bool autoOpen)
|
|
{
|
|
string searchPanelText = StringResourcesUtil.GetString(226);
|
|
StringBuilder beforeContent = new StringBuilder();
|
|
|
|
if (autoOpen)
|
|
beforeContent.Append("<div class=\"searchPanel\"><ul id=\"searchPanelUl\"><li class=\"k-state-active\"><span>").Append(searchPanelText).Append("</span><div><div>");
|
|
else
|
|
beforeContent.Append("<div class=\"searchPanel\"><ul id=\"searchPanelUl\"><li><span>").Append(searchPanelText).Append("</span><div><div>");
|
|
|
|
html.ViewContext.Writer.Write(beforeContent.ToString());
|
|
}
|
|
|
|
public static void SearchPanelEnd(this HtmlHelper html)
|
|
{
|
|
StringBuilder endContent = new StringBuilder();
|
|
endContent.Append("</div></div></li></ul></div>");
|
|
|
|
html.ViewContext.Writer.Write(endContent.ToString());
|
|
}
|
|
|
|
public class SearchPanelHelper : IDisposable
|
|
{
|
|
private readonly HtmlHelper rohtml;
|
|
|
|
public SearchPanelHelper(HtmlHelper html)
|
|
{
|
|
rohtml = html;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
rohtml.SearchPanelEnd();
|
|
}
|
|
}
|
|
}
|
|
}
|