Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
hideCol disable D&D column
30/06/2014
09:56
Avatar
pawelo
Member
Members
Forum Posts: 3
Member Since:
30/06/2014
sp_UserOfflineSmall Offline
 
Hi

I have jqGrid with option sortable = true - I can D&D columns - change order column.
When I use hideCol I can't change order columns.

What does I need?

in showHideCol i commented line if(gh) { $($t).jqGrid('destroyGroupHeader', false); } and it work but ...

why doesn't work this code
if( gh ) {
$($t).jqGrid('setGroupHeaders',$t.p.groupHeader);
}

 
 
08/07/2014
11:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,
I'm not sure that I can help when using this type of description.
Please post your code or send a link to the problem.

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

09/07/2014
12:13
Avatar
pawelo
Member
Members
Forum Posts: 3
Member Since:
30/06/2014
sp_UserOfflineSmall Offline

Example:

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script type="text/javascript" src="http://trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript" src="http://trirand.com/blog/jqgrid/js/jquery.jqGrid.src.js"></script>

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="http://trirand.com/blog/jqgrid/themes/ui.jqgrid.css"/>

<script type="text/javascript">

var jqgridNames;
var jqgridModel;
var jqgridRowNum;
var jqgridRowList;
var jqgridPager;
var jqgridSortName;
var jqgridCaption;

var jqgriddbDane;
var jqgriddane;
var jqgridPage;
var jqgridTotal;
var jqgridRecords;
var jqgridHeight;
var jqgridWidth;
var jqgridGroupHeaders;
var jqgridShrinkToFit;
var jqgridRownumbers;
var jqgridSearch;
var jqgridViewrecords;
var jqgridScrollrows;
var jqgridToppager;
var jqgridMultiselect;
var jqgridFiltr;
var jqgridFrizenColumn;
var jqgridFilterToolbar;
var jqgridSortOrder;
var jqgridMultiSort;
var jqgridFooterrow;
var jqgridProcedura;
var jqgridSortable;

var GridProcUstawienia;
var GridProcDane;
var GridProcPozycjiUstawienia;
var GridProcPozycjiDane;
var ExportListyDoExcel;

var mypostdata;

var hdfGridRowNum;
var hdfGridRowList;

var szerZWidocznymiAkcjami = 380;
var szerZUkrytymiAkcjami = 210;

var OdejmijJakJestTabWOknie = 0;

var szerokoscGlob;
var idPoprzedniegoRekordu;

var boolDodaj = false;
var boolEdytuj = false;

var ile = 0;

var configChzn = {
'.chzn-select': {},
'.chzn-select-deselect': { allow_single_deselect: true, width: "400px !important", height: "60px", no_results_text: 'Brak pozycji o podanej nazwie' },
'.chzn-select-no-single': { disable_search_threshold: 10 },
'.chzn-select-no-results': { no_results_text: 'Nic nie znalazłem' },

'.chzn-select-width': { width: "95%" }
}

//----------------------------------------
function PodstawUstawieniaGrida() {
var a = JSON.parse('{"colNames": ["id", "Akcje", "Login", "Symbol", "Nazwisko", "Imię", "e-mail", "Aktywny", "Ostatnie logowanie"], "colModel": [ {"name": "id", "index": "id", "width": 50, "frozen": false, "hidden": true}, {"name": "act", "index": "act", "width": 100, "frozen": true, "sortable": false, "search": false}, {"name": "UserId", "index": "UserId", "width": 160, "searchoptions": { "sopt": ["cn", "bw", "ne", "nc"]}, "search": true}, {"name": "userSymbol", "index": "userSymbol", "width": 70, "searchoptions": { "sopt": ["cn", "bw", "ne", "nc"]}, "search": true}, {"name": "userNazwisko", "index": "userNazwisko", "width": 200, "searchoptions": { "sopt": ["cn", "bw", "ne", "nc"]}, "search": true}, {"name": "userImie", "index": "userImie", "width": 120, "searchoptions": { "sopt": ["cn", "bw", "ne", "nc"]}, "search": true}, {"name": "Email", "index": "Email", "width": 220, "searchoptions": { "sopt": ["cn", "bw", "ne", "nc"]}, "search": true}, {"name": "IsApproved", "index": "IsApproved", "width":85, "searchoptions": { "value": ":;1:Tak;0:Nie", "sopt": ["eq", "ne"], "odata": ["eq", "ne"]}, "formatter": "checkbox", "edittype": "checkbox", "editoptions": {"value": "1:0"}, "stype": "select", "align": "center", "sortable": "false", "editable": "true"}, {"name": "LastLoginDate","index": "LastLoginDate","width": 140, "searchoptions": { "sopt": ["cn", "bw", "ne", "nc"]}, "search": true} ], "rowNum": 20, "rowList": [10,20,50], "pager": "#divDanePager", "sortname": "UserName", "caption": "Lista użytkowników", "groupHeaders": [], "height": "340", "width": "100", "shrinkToFit": false, "rownumbers": false, "search": true, "viewrecords": true, "scrollrows": true, "toppager": false, "search": true, "multiselect": true, "page": "0", "total": "0", "records": "0", "filtr": "", "frozenColumn": false, "filterToolbar": true, "procedura": "dbo.PobierzDane"}');

jqgridNames = a.colNames;
jqgridModel = a.colModel;

jqgridRowNum = a.rowNum;

jqgridPager = a.pager;
jqgridSortName = a.sortname;
jqgridCaption = a.caption;
jqgridGroupHeaders = a.groupHeaders;
jqgridHeight = a.height;
jqgridWidth = a.width;
jqgridPage = a.page;
jqgridTotal = a.total;
jqgridRecords = a.records;
jqgridShrinkToFit = a.shrinkToFit;
jqgridRownumbers = a.rownumbers;
jqgridSearch = a.search;
jqgridViewrecords = a.viewrecords;
jqgridScrollrows = a.scrollrows;

jqgridToppager = true;
jqgridMultiselect = a.multiselect;
jqgridFiltr = a.filtr;
jqgridFrizenColumn = a.frozenColumn;
jqgridFilterToolbar = a.filterToolbar;
jqgridSortOrder = a.sortorder;
jqgridMultiSort = a.multiSort;
jqgridFooterrow = a.footerrow;
if (a.procedura != null && a.procedura != undefined && a.procedura != "") {
jqgridProcedura = a.procedura;
jqgridSortable = true;

if (jqgridProcedura.indexOf("DoDlg") > 0) {
jqgridProcedura = null;
jqgridSortable = false;
}
}
else {
jqgridProcedura = null;
jqgridSortable = false;
}
}

function getColumnIndexByName(grid, columnName) {
var cm = grid.jqGrid('getGridParam', 'colModel'), i = 0, l = cm.length;
for (; i < l; i += 1) {
if (cm[i].name === columnName) {
return i;
}
}
return -1;
}

function refreshSerchingToolbar($grid, myDefaultSearch) {
var postData = $grid.jqGrid('getGridParam', 'postData'), filters, i, l,
rules, rule, iCol, cm = $grid.jqGrid('getGridParam', 'colModel'),
cmi, control, tagName;

for (i = 0, l = cm.length; i < l; i += 1) {
control = $("#gs_" + $.jgrid.jqID(cm[i].name));
if (control.length > 0) {
tagName = control[0].tagName.toUpperCase();
if (tagName === "SELECT") { // && cmi.stype === "select"
control.find("option[value='']")
.attr('selected', 'selected');
} else if (tagName === "INPUT") {
control.val('');
}
}
}

if (typeof (postData.filters) === "string" && typeof ($grid[0].ftoolbar) === "boolean" && $grid[0].ftoolbar) {
filters = $.parseJSON(postData.filters);
if (filters && filters.groupOp === "AND" && typeof (filters.groups) === "undefined") {
rules = filters.rules;
for (i = 0, l = rules.length; i < l; i += 1) {
rule = rules[i];
iCol = getColumnIndexByName($grid, rule.field);
control = $("#gs_" + $.jgrid.jqID(rule.field));
if (iCol >= 0) {
cmi = cm[iCol];
tagName = control[0].tagName.toUpperCase();
if (((typeof (cmi.searchoptions) === "undefined" ||
typeof (cmi.searchoptions.sopt) === "undefined")
&& rule.op === myDefaultSearch) ||
(typeof (cmi.searchoptions) === "object" &&
$.isArray(cmi.searchoptions.sopt) &&
cmi.searchoptions.sopt[0] === rule.op)) {

if (tagName === "SELECT") { // && cmi.stype === "select"
control.find("option[value='" + $.jgrid.jqID(rule.data) + "']")
.attr('selected', 'selected');
} else if (tagName === "INPUT") {
control.val(rule.data);
}
} else {
control.val("");
}
}
}
}
}
}

function LadujGrida(grid, szerokoscGrida, proceduraDane, funkcjaAkcji, bExport, funkcjaEksportu, proceduraEksportu,
pokazKolCB, bUkryjKolAct, stopkaGrida, przycisk, PodstawIdDo, MenuKontekstowe, czyJestDetail, gridPozycji, labelkaFiltru,
funWykonajPoZaladowaniuDanych, wysokoscGrida, funWykonajKiedyGridJestKompletny, funWykonajPoZaznaczeniuWiersza,
funWykonajPoSortowaniuNaKolumnie, contextMenu, obiekt) {

var argumenty = arguments;
var divGrid = $(grid);
if (grid.length > 1) {
var gridTemp = grid.replace("#", "");
if ($("#gbox_" + gridTemp).length > 0) {
var parent = $("#gbox_" + gridTemp).parent();
var pager = stopkaGrida.replace("#", "");
$("#gbox_" + gridTemp).remove();
$(parent).append('<table id="' + gridTemp + '" style="width: 100%; height: 100%;"></table><div id="' + pager + '"></div>');
}
}

var parentGrida = divGrid.parent();

PodstawUstawieniaGrida();
$(this).unbind('ajaxStop');

var idsOfSelectedRows = [];
var idsOfSelectedRowsOpisy = [];

if (obiekt != null) {
idsOfSelectedRowsOpisy = obiekt.idsOfSelectedRowsOpisy;
}

var updateIdsOfSelectedRows = function (id, isSelected) {
var index = $.inArray(id, idsOfSelectedRows);
if (!isSelected && index >= 0) {
idsOfSelectedRows.splice(index, 1); // remove id from the list
} else if (index < 0) {
var wiersz = $(grid).jqGrid('getRowData', id);

if (wiersz.ukryjZaz != undefined && wiersz.ukryjZaz != 1) {
idsOfSelectedRows.push(id);

var wiersz = $(grid).jqGrid('getRowData', id);
if (wiersz != null && wiersz.opis != null && wiersz.opis != undefined) {
var o = {
id: id,
opis: wiersz.opis
};

var jest = false;
for (var i = 0; i < idsOfSelectedRowsOpisy.length; i++) {
if (idsOfSelectedRowsOpisy[i].id == id) {
jest = true;
}
}

if (!jest) {
idsOfSelectedRowsOpisy.push(o);
}
}
}

if (wiersz.ukryjZaz == undefined) {
idsOfSelectedRows.push(id);
}
}
};

if (szerokoscGrida == null) {
szerokoscGrida = $('#tabs-0').width() - 370
}

if (wysokoscGrida != null) {
jqgridHeight = wysokoscGrida;
}

if (jqgridSortOrder == undefined) {
jqgridSortOrder = "asc";
}
if ((jqgridSortOrder != "asc") && (jqgridSortOrder != "desc")) {
jqgridSortOrder = "asc";
}

if (jqgridMultiSort == undefined || jqgridMultiSort == null) {
jqgridMultiSort = false;
}

mydata = JSON.parse('{"total": "2", "page": "1", "records": "31", "filtr": "", "rows": [{"id": "C7F55ADB-9FC0-45CB-81B1-C3BAB9B48D85", "cell" : ["C7F55ADB-9FC0-45CB-81B1-C3BAB9B48D85", "", "C7F55ADB-9FC0-45CB-81B1-C3BAB9B48D85", "", "", "PO", "porchowski@xxx.aaa.pl", "1", "2014-07-09 06:31:13", ""]},{"id": "45214ECA-FD3A-4081-99B8-0276786C8A50", "cell" : ["45214ECA-FD3A-4081-99B8-0276786C8A50", "", "45214ECA-FD3A-4081-99B8-0276786C8A50", "", "1", "PO1", "porchow@xxx.aaa.pl", "1", "2014-03-21 08:42:40", ""]}]}');

$(grid).jqGrid({
sortable: jqgridSortable,
mtype: "POST",
async: false,
data: mydata,
datatype: 'local',
colNames: jqgridNames,
colModel: jqgridModel,
rowNum: jqgridRowNum,
rowList: jqgridRowList,
pager: jqgridPager,
sortname: jqgridSortName,
sortorder: jqgridSortOrder,
search: jqgridSearch,
viewrecords: jqgridViewrecords,
scrollrows: jqgridScrollrows,
width: szerokoscGrida,
caption: jqgridCaption,
footerrow: jqgridFooterrow,
autowidth: true,
multiSort: jqgridMultiSort,
toppager: jqgridToppager,
shrinkToFit: jqgridShrinkToFit,
rownumbers: jqgridRownumbers,
multiselect: jqgridMultiselect,
editurl: "",
gridComplete: function () {
var g = $(grid);
g.height = $("#divLewy").css("height");

var ids = g.getDataIDs();
},
loadError: function (xhr, st, err) {
},
loadComplete: function (dane) {
dane = mydata;

if (grid.selector != undefined) {
var nazGrida = grid.selector.replace("#", "");
for (var i = 0; i < dane.rows.length; i++) {
var wiersz = dane.rows[i];
if (dane.rows[i].ukryjZaz != undefined && dane.rows[i].ukryjZaz == "1") {
$("#jqg_" + nazGrida + "_" + dane.rows[i].id).css("visibility", "hidden");
$("#jqg_" + nazGrida + "_" + dane.rows[i].id).attr("disabled", true);
}
}
}

refreshSerchingToolbar($(this), 'cn');
var $this = $(this), i, count;
for (i = 0, count = idsOfSelectedRows.length; i < count; i++) {
$this.jqGrid('setSelection', idsOfSelectedRows[i], false);
}
}
});

$(grid).jqGrid('navGrid', jqgridPager, { search: jqgridSearch, edit: false, add: false, del: false, searchtext: "Szukaj" },
{}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true }, {}, { cloneToTop: true });

//Łączenie opisów kolumn
$(grid).jqGrid('setGroupHeaders', {
useColSpanStyle: true,
groupHeaders: jqgridGroupHeaders
});

if (jqgridFilterToolbar) {
$(grid).jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, ignoreCase: true, searchoptions: { sopt: ["cn"]} });
}

if (bUkryjKolAct != false) {
$(grid).hideCol("act");
}

if (jqgridProcedura != "" && jqgridProcedura != undefined && jqgridProcedura != null) {
PokazUkryjKolumnyZapisane(grid);
}
else {
PokazUkryjKolumny(grid);
}
}

function PokazUkryjKolumnyZapisane(g) {
var sDivPagerKolumny = zamienWTekscie(g, "gvw", "div") + "Pager .ui-icon-bookmark";

var arrKolumny = $(sDivPagerKolumny);

if (arrKolumny.length == 0) {
$(g).jqGrid('navButtonAdd', jqgridPager, {
caption: "Kolumny", buttonicon: "ui-icon-bookmark", title: "Kolumny pokaż/ukryj",
onClickButton: function () {
$(g).jqGrid('columnChooser', {
done: function (perm) {
if (perm) {
this.jqGrid("remapColumns", perm, true);
this.jqGrid({ sortable: true });
} else {
}
}
});
}
});
}
}

function PokazUkryjKolumny(g) {
$(g).jqGrid('navButtonAdd', jqgridPager, {
caption: "Kolumny", buttonicon: "ui-icon-bookmark", title: "Kolumny pokaż/ukryj",
onClickButton: function () {
$(g).jqGrid('columnChooser', {
done: function (perm) {
if (perm) {
this.jqGrid("remapColumns", perm, true);
} else {
}
}
});
}
});
}

function zamienWTekscie(tekst, co, na) {
while (tekst.indexOf(co) != -1) {
tekst = tekst.replace(co, na);
};
return tekst;
}

$(document).ready(function () {
LadujGrida("#gvwDane", null, null, null, true, null, null, false, false, null,
$('<%= "#" + btZaznaczonyId.ClientID %>'), $('<%= "#" + hdfZaznaczonyId.ClientID %>'), null, 0, null, '#lFiltr', null,
null, null, null, null, null);
});
</script>
</head>
<body>
<div id="divWlasciwy" style="float: left; padding-left: 10px; width: 100%">
<div id="panOkno" style="width: 100%; height: 100% !important">
<asp:HiddenField ID="hdfGridRowNum" runat="server" />
<asp:HiddenField ID="hdfGridRowList" runat="server" />
<asp:HiddenField ID="hdfZaznaczonyId" runat="server" Value="" />
<asp:Button ID="btZaznaczonyId" runat="server" Text="Zaznaczony id" CssClass="UkryjButton" />
<div id="divListyZDanymi" style="width: 100%; height: 700px !important">
<label id="lFiltr">
</label>
<table id="gvwDane" style="width: 100%; height: 100% !important">
</table>
<div id="divDanePager">
</div>
</div>
</div>
</div>
</body>
</html>

21/07/2014
11:51
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Wow I need a days to understand this. The code is a complex with too many functions.
Of course if the column is hidden it stays on position where you hide it.

Kind regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

24/07/2014
15:10
Avatar
pawelo
Member
Members
Forum Posts: 3
Member Since:
30/06/2014
sp_UserOfflineSmall Offline

I have hidden column at start (column Id), but when I commented line "if(gh) { $($t).jqGrid('destroyGroupHeader', false);}" in jqueryj.jqGrid.src.js -> showHideCol is better, but problem is when I use groupHeader.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
76 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information