Пример #1
0
 public static JqGridHelper <T> UseInlineEditingScripts <T>(this JqGridHelper <T> helper, bool add = true, string addPreifx = "", bool edit = true, string editPrefix = "")
 {
     if (helper.InlineNavigatorOptions == null)
     {
         throw new NullReferenceException("Inline navigator must be enabled");
     }
     if (add)
     {
         if (helper.InlineNavigatorOptions.AddActionOptions == null)
         {
             helper.InlineNavigatorOptions.AddActionOptions = new JqGridInlineNavigatorAddActionOptions();
         }
         if (helper.InlineNavigatorOptions.AddActionOptions.Options == null)
         {
             helper.InlineNavigatorOptions.AddActionOptions.Options = new JqGridInlineNavigatorActionOptions();
         }
         helper.InlineNavigatorOptions.AddActionOptions.Options.AfterSaveFunction = GetInlineAfterSaveFunction(helper.Id, addPreifx);
         helper.InlineNavigatorOptions.AddActionOptions.Options.SuccessFunction   = GetInlineSuccessFunction(helper.Id, addPreifx);
     }
     if (edit)
     {
         if (helper.InlineNavigatorOptions.ActionOptions == null)
         {
             helper.InlineNavigatorOptions.ActionOptions = new JqGridInlineNavigatorActionOptions();
         }
         helper.InlineNavigatorOptions.ActionOptions.AfterSaveFunction = GetInlineAfterSaveFunction(helper.Id, editPrefix);
         helper.InlineNavigatorOptions.ActionOptions.SuccessFunction   = GetInlineSuccessFunction(helper.Id, editPrefix);
     }
     return(helper);
 }
        protected override IList <LocalizationGridModel> FetchData(GridSettings gridSettings)
        {
            var query = _repository.Query();

            Random rand       = new Random((int)DateTime.Now.Ticks);
            var    gridResult = JqGridHelper.GetGridResult(query, delegate(string fieldName)
            {
                return(fieldName);
            },
                                                           delegate(Localization model)
            {
                return(new LocalizationGridModel()
                {
                    Id = rand.Next(int.MaxValue),
                    //LocalizationId = model.Id,
                    Key = model.Key,
                    Value = model.Value,
                    JavaScript = model.JavaScript,
                    Language = model.Language
                });
            }
                                                           , gridSettings);

            return(gridResult);
        }
Пример #3
0
 public static JqGridHelper <T> UseFormEditingScripts <T>(this JqGridHelper <T> helper, bool add = true, string addPrefix = "", bool edit = true, string editPrefix = "", bool delete = true, string deletePrefix = "")
 {
     if (helper.NavigatorOptions == null)
     {
         throw new NullReferenceException("Navigator must be enabled");
     }
     if (add)
     {
         if (helper.NavigatorAddOptions == null)
         {
             throw new NullReferenceException("Add action options must be not null");
         }
         helper.NavigatorAddOptions.AfterSubmit = GetFormAfterSubmitFunction(helper.Id, addPrefix);
     }
     if (edit)
     {
         if (helper.NavigatorEditOptions == null)
         {
             throw new NullReferenceException("Edit action options must be not null");
         }
         helper.NavigatorEditOptions.AfterSubmit = GetFormAfterSubmitFunction(helper.Id, editPrefix);
     }
     if (delete)
     {
         if (helper.NavigatorDeleteOptions == null)
         {
             throw new NullReferenceException("Delete action options must be not null");
         }
         helper.NavigatorDeleteOptions.AfterSubmit = GetFormAfterSubmitFunction(helper.Id, deletePrefix);
     }
     //helper.NavigatorAddOptions
     return(helper);
 }
Пример #4
0
 private JqGridData GetGridData(JqGridRequest request, IQueryable <MovieListDO> movieList)
 {
     //JqGridRequest request = new JqGridRequest( ) {
     //	_search = false,
     //	filters = null,
     //	page = 1,
     //	rows = 5,
     //	searchField = null,
     //	searchOper = null,
     //	searchString = null,
     //	sidx = "ID",
     //	sord = "asc"
     //};
     return(JqGridHelper <MovieListDO> .ToJqGridData(request, movieList, m => new JqGridRowItem {
         id = m.Movie.ID,
         cell = new object[]
         {
             m.Movie.ID,
             GetFullPathForImage(m.Movie.ImdbPosterPath),
             m.OriginalName,
             m.EnglishName,
             m.TurkishName,
             m.Movie.Year,
             m.Movie.ImdbRating,
             m.Movie.ImdbID,
             GetFormattedDate(m.Movie.InsertDate),
             GetFormattedDate(m.Movie.UpdateDate)
         }
     }));
 }
Пример #5
0
        /// <summary>
        /// Ги зема податоците за сите корисници од тип Администратор по
        /// сите општини и МТВ
        /// </summary>
        /// <param name="gridSettings"></param>
        /// <returns></returns>
        protected override IList <ZelsUsersGridModel> FetchData(GridSettings gridSettings)
        {
            var query = _userRepository.Query()
                        .Where(x => x.Roles.Any(r => r.RoleName == Roles.MunicipalityAdministrator ||
                                                r.RoleName == Roles.ExternalUsers ||
                                                r.RoleName == Roles.UpravenInspektor
                                                ));

            var gridResult = JqGridHelper.GetGridResult(query, delegate(string fieldName)
            {
                switch (fieldName)
                {
                case "Institution.Name":
                    return("Institution.Id");
                }

                return(fieldName);
            },
                                                        delegate(User model)
            {
                return(model.MapToViewModel());
            }
                                                        , gridSettings);

            return(gridResult);
        }
Пример #6
0
        public static MvcHtmlString GetJavaScriptInlineFunctions <TModel>(this JqGridHelper <TModel> grid, string prefix = "", string customFunctionAfterSave = null, string customSuccessFunction = null)
        {
            var result = new StringBuilder();

            result.AppendFormat("function {0}(rowid,response) {{\n", GetInlineAfterSaveFunction(grid.Id, prefix))
            .AppendLine(@"	let data;
	try {
		data = JSON.parse(response.responseText);
		if (data.rowid)
			$(`#${rowid}`).attr(""id"", data.rowid);
	}
	catch (e) {
		return;
	}"    );
            if (!string.IsNullOrWhiteSpace(customFunctionAfterSave))
            {
                result.AppendFormat("\t{0}.call(this,rowid,response);\n", customFunctionAfterSave);
            }
            result.AppendLine("}")
            .AppendLine()
            .AppendFormat("function {0}(response) {{\n", GetInlineSuccessFunction(grid.Id, prefix))
            .AppendLine(@"	let data, result = false;
	try {
		data = JSON.parse(response.responseText);
		if (data.success) {
			result = true;
		} else {
			if (data.message)
				alert(data.message);
			$(""#Grid"").jqGrid('showAddEditButtons');
		}
	}
	catch (e) {
		result = false;
	}"    );
            if (!string.IsNullOrWhiteSpace(customSuccessFunction))
            {
                result.AppendFormat("\tconst sucret = {0}.call(this,response,result);\n", customSuccessFunction)
                .AppendLine("\treturn sucret || result;");
            }
            else
            {
                result.AppendLine("\treturn result;");
            }
            result.Append("}");
            if (!HttpContext.Current.IsDebuggingEnabled)
            {
                result.Replace("\n", "").Replace("\t", "");
            }
            return(new MvcHtmlString(result.ToString()));
        }
Пример #7
0
 private JqGridData GetGridData(JqGridRequest request, IQueryable <MovieListDO> movieList)
 {
     return(JqGridHelper <MovieListDO> .ToJqGridData(request, movieList, m => new JqGridRowItem {
         id = m.Movie.ID,
         cell = new object[]
         {
             m.Movie.ID,
             GetFullPathForImage(m.Movie.ImdbPosterPath),
             m.OriginalName,
             m.EnglishName,
             m.TurkishName,
             m.Movie.Year,
             m.Movie.ImdbRating,
             m.Movie.ImdbID,
             GetFormattedDate(m.Movie.InsertDate),
             GetFormattedDate(m.Movie.UpdateDate)
         }
     }));
 }
Пример #8
0
        protected override IList <PosGridModel> FetchData(GridSettings gridSettings)
        {
            var query = _posRepository.Query();

            var gridResult = JqGridHelper.GetGridResult(query, delegate(string fieldName)
            {
                switch (fieldName)
                {
                    //case "Institution.Name":
                    //    return "Institution.Id";
                }

                return(fieldName);
            },
                                                        delegate(Pos model)
            {
                return(model.MapToViewModel());
            }
                                                        , gridSettings);

            return(gridResult);
        }
Пример #9
0
        protected override IList <UsersGridModel> FetchData(GridSettings gridSettings)
        {
            var query = _userRepository.Query()
                        .Where(x => x.Roles.Any(r => r.RoleName == Roles.Admin));

            var gridResult = JqGridHelper.GetGridResult(query, delegate(string fieldName)
            {
                switch (fieldName)
                {
                    //case "Institution.Name":
                    //    return "Institution.Id";
                }

                return(fieldName);
            },
                                                        delegate(User model)
            {
                return(model.MapToViewModel());
            }
                                                        , gridSettings);

            return(gridResult);
        }