8a47bb616727baba4487354376235d9a1273c07d
API/CodeSamples/Javascript/StickyCheckboxes/ReportViewerFilters.js
| ... | ... | @@ -0,0 +1,1086 @@ |
| 1 | +var filtersData = new Array();
|
|
| 2 | +var subreportsFiltersData;
|
|
| 3 | +var showingC = false;
|
|
| 4 | +var calendars;
|
|
| 5 | +var filtersDataObtained = false;
|
|
| 6 | +var makeFiltersFloat;
|
|
| 7 | +var refreshFiltersLastGUID = '';
|
|
| 8 | +
|
|
| 9 | +function ToggleFilters() {
|
|
| 10 | + var filtersBodyDiv$ = jq$('#filtersBodyDiv');
|
|
| 11 | + if (filtersBodyDiv$.css('visibility') == 'hidden') {
|
|
| 12 | + filtersBodyDiv$.css('visibility', 'visible');
|
|
| 13 | + filtersBodyDiv$.css('height', 'auto');
|
|
| 14 | + }
|
|
| 15 | + else {
|
|
| 16 | + filtersBodyDiv$.css('visibility', 'hidden');
|
|
| 17 | + filtersBodyDiv$.css('height', '0px');
|
|
| 18 | + }
|
|
| 19 | +}
|
|
| 20 | +
|
|
| 21 | +/**
|
|
| 22 | +* Returns value(s) for filter with number (index)
|
|
| 23 | +*/
|
|
| 24 | +function GetFilterValues(index, filters, id) {
|
|
| 25 | + if (filters == null)
|
|
| 26 | + filters = filtersData;
|
|
| 27 | + if (id == null)
|
|
| 28 | + id = index;
|
|
| 29 | +
|
|
| 30 | + var result = new Array();
|
|
| 31 | + result[0] = '';
|
|
| 32 | + switch (filters[index].ControlType) {
|
|
| 33 | + case 1:
|
|
| 34 | + case 11:
|
|
| 35 | + case 100:
|
|
| 36 | + var pItem = document.getElementById('ndbfc' + id).parentElement;
|
|
| 37 | + if (filters[index].ControlType == 11)
|
|
| 38 | + pItem = pItem.parentElement;
|
|
| 39 | + result[0] = pItem.id;
|
|
| 40 | + result[1] = document.getElementById('ndbfc' + id).value;
|
|
| 41 | + break;
|
|
| 42 | + case 2:
|
|
| 43 | + result[0] = document.getElementById('ndbfc' + id + '_l').parentElement.id;
|
|
| 44 | + result[1] = document.getElementById('ndbfc' + id + '_l').value;
|
|
| 45 | + result[2] = document.getElementById('ndbfc' + id + '_r').value;
|
|
| 46 | + break;
|
|
| 47 | + case 3:
|
|
| 48 | + result[0] = document.getElementById('ndbfc' + id).parentElement.id;
|
|
| 49 | + result[1] = document.getElementById('ndbfc' + id).value;
|
|
| 50 | + break;
|
|
| 51 | + case 4:
|
|
| 52 | + result[0] = document.getElementById('ndbfc' + id).parentElement.id;
|
|
| 53 | + result[1] = document.getElementById('ndbfc' + id).value;
|
|
| 54 | + break;
|
|
| 55 | + case 5:
|
|
| 56 | + result[0] = document.getElementById('ndbfc' + id + '_1').parentElement.id;
|
|
| 57 | + result[1] = document.getElementById('ndbfc' + id + '_1').value;
|
|
| 58 | + result[2] = document.getElementById('ndbfc' + id + '_2').value;
|
|
| 59 | + break;
|
|
| 60 | + case 6:
|
|
| 61 | + result[0] = document.getElementById('ndbfc' + id).parentElement.id;
|
|
| 62 | + result[1] = document.getElementById('ndbfc' + id).value;
|
|
| 63 | + break;
|
|
| 64 | + case 7:
|
|
| 65 | + result[0] = document.getElementById('ndbfc' + id).parentElement.id;
|
|
| 66 | + result[1] = document.getElementById('ndbfc' + id).value;
|
|
| 67 | + break;
|
|
| 68 | + case 8:
|
|
| 69 | + result[0] = document.getElementById('ndbfc' + id).parentElement.id;
|
|
| 70 | + var combinedRes8 = '';
|
|
| 71 | + var cnt8 = 0;
|
|
| 72 | + var cb = document.getElementById('ndbfc' + id + '_cb' + cnt8);
|
|
| 73 | + while (cb != null) {
|
|
| 74 | + if (cb.checked) {
|
|
| 75 | + if (combinedRes8.length > 0)
|
|
| 76 | + combinedRes8 += ',';
|
|
| 77 | + combinedRes8 += cb.value;
|
|
| 78 | + }
|
|
| 79 | + cnt8++;
|
|
| 80 | + cb = document.getElementById('ndbfc' + id + '_cb' + cnt8);
|
|
| 81 | + }
|
|
| 82 | + result[1] = combinedRes8;
|
|
| 83 | + break;
|
|
| 84 | + case 9:
|
|
| 85 | + result[0] = document.getElementById('ndbfc' + id).parentElement.id;
|
|
| 86 | + result[1] = document.getElementById('ndbfc' + id).value;
|
|
| 87 | + break;
|
|
| 88 | + case 10:
|
|
| 89 | + result[0] = document.getElementById('ndbfc' + id).parentElement.id;
|
|
| 90 | + var combinedRes = '';
|
|
| 91 | + var selCtl = document.getElementById('ndbfc' + id);
|
|
| 92 | + for (var cnt10 = 0; cnt10 < selCtl.options.length; cnt10++) {
|
|
| 93 | + if (selCtl.options[cnt10].selected) {
|
|
| 94 | + if (combinedRes.length > 0)
|
|
| 95 | + combinedRes += ',';
|
|
| 96 | + combinedRes += selCtl.options[cnt10].value;
|
|
| 97 | + }
|
|
| 98 | + }
|
|
| 99 | + result[1] = combinedRes;
|
|
| 100 | + break;
|
|
| 101 | + default:
|
|
| 102 | + break;
|
|
| 103 | + }
|
|
| 104 | + return result;
|
|
| 105 | +}
|
|
| 106 | +
|
|
| 107 | +/**
|
|
| 108 | +* Save filters stored in 'filtersData' variable.
|
|
| 109 | +*/
|
|
| 110 | +function CommitChangedFilter(field) {
|
|
| 111 | + if (field.FilterGUID) {
|
|
| 112 | + for (var i = 0; i < filtersData.length; i++)
|
|
| 113 | + if (filtersData[i].GUID == field.FilterGUID) {
|
|
| 114 | + filtersData[i].OperatorValue = field.FilterOperator;
|
|
| 115 | + break;
|
|
| 116 | + }
|
|
| 117 | + }
|
|
| 118 | + CommitFiltersData(false);
|
|
| 119 | +}
|
|
| 120 | +
|
|
| 121 | +function CommitFiltersData(updateReportSet) {
|
|
| 122 | + var dataToCommit = new Array();
|
|
| 123 | + dataToCommit = dataToCommit.concat(GetFiltersDataToCommit());
|
|
| 124 | + dataToCommit = dataToCommit.concat(GetSubreportsFiltersDataToCommit());
|
|
| 125 | +
|
|
| 126 | + if (dataToCommit.length == 0) {
|
|
| 127 | + GetRenderedReportSet(true);
|
|
| 128 | + return;
|
|
| 129 | + }
|
|
| 130 | +
|
|
| 131 | + filtersDataObtained = false;
|
|
| 132 | +
|
|
| 133 | + // Save scroll position within the checkbox filters' divs
|
|
| 134 | + var positions = [];
|
|
| 135 | + jq$('#htmlFilters .saveScroll').each(function () {
|
|
| 136 | + if (!jq$(this).attr('id') || this.scrollTop == 0)
|
|
| 137 | + return;
|
|
| 138 | + positions.push(
|
|
| 139 | + {
|
|
| 140 | + id: jq$(this).attr('id'),
|
|
| 141 | + scroll: this.scrollTop
|
|
| 142 | + });
|
|
| 143 | + });
|
|
| 144 | + // Disable filters so they cannot be changed until they are in the relevant state
|
|
| 145 | + jq$('#htmlFilters :input').prop('disabled', true);
|
|
| 146 | +
|
|
| 147 | + var cmd = 'setfiltersdata';
|
|
| 148 | + if (!updateReportSet)
|
|
| 149 | + cmd = 'refreshcascadingfilters';
|
|
| 150 | + var requestString = 'wscmd=' + cmd + '&wsarg0=' + encodeURIComponent(JSON.stringify(dataToCommit));
|
|
| 151 | + // Instant Report handling
|
|
| 152 | + if (typeof nirConfig != 'undefined' && nirConfig != null && typeof dataSources != 'undefined' && dataSources != null) {
|
|
| 153 | + var ds = new Array();
|
|
| 154 | + for (var i = 0; i < dataSources.length; i++)
|
|
| 155 | + ds.push(dataSources[i].DbName);
|
|
| 156 | + requestString += '&wsarg1=' + encodeURIComponent(JSON.stringify(ds));
|
|
| 157 | + }
|
|
| 158 | + refreshFiltersLastGUID = GenerateGuid();
|
|
| 159 | + if (updateReportSet)
|
|
| 160 | + AjaxRequest(urlSettings.urlRsPage, requestString, FiltersDataSet, null, 'setfiltersdata');
|
|
| 161 | + else
|
|
| 162 | + AjaxRequest(urlSettings.urlRsPage, requestString, function (returnObj, id) {
|
|
| 163 | + CascadingFiltersChanged(returnObj, id);
|
|
| 164 | + for (var i = 0; i < positions.length; i++) {
|
|
| 165 | + if (jq$('#' + positions[i].id) != null)
|
|
| 166 | + jq$('#' + positions[i].id)[0].scrollTop = positions[i].scroll;
|
|
| 167 | + }
|
|
| 168 | + }, null, 'refreshcascadingfilters-' + refreshFiltersLastGUID);
|
|
| 169 | +}
|
|
| 170 | +
|
|
| 171 | +function GetFiltersDataToCommit() {
|
|
| 172 | + var dataToCommit = new Array();
|
|
| 173 | + if (filtersData == null || filtersData.length <= 0)
|
|
| 174 | + return dataToCommit;
|
|
| 175 | +
|
|
| 176 | + for (var index = 0; index < filtersData.length; index++) {
|
|
| 177 | + var filterObj = new Object();
|
|
| 178 | + filterObj.Removed = filtersData[index].Removed;
|
|
| 179 | + filterObj.Uid = filtersData[index].Uid;
|
|
| 180 | + filterObj.GUID = filtersData[index].GUID;
|
|
| 181 | + filterObj.Column = filtersData[index].ColumnName;
|
|
| 182 | + filterObj.FieldFilter = filtersData[index].FieldFilter;
|
|
| 183 | + filterObj.OperatorValue = filtersData[index].OperatorValue;
|
|
| 184 | + filterObj.AliasTable = filtersData[index].AliasTable;
|
|
| 185 | + if (!filtersData[index].Removed)
|
|
| 186 | + filterObj.Values = GetFilterValues(index, filtersData).slice(1);
|
|
| 187 | + dataToCommit[index] = filterObj;
|
|
| 188 | + }
|
|
| 189 | + return dataToCommit;
|
|
| 190 | +}
|
|
| 191 | +
|
|
| 192 | +function UpdateFiltersDataValuesFromUI() {
|
|
| 193 | + for (var index = 0; index < filtersData.length; index++) {
|
|
| 194 | + var filterValues = GetFilterValues(index, filtersData);
|
|
| 195 | + filtersData[index].Values = filterValues;
|
|
| 196 | + filtersData[index].Value = filterValues.slice(1);
|
|
| 197 | + }
|
|
| 198 | +}
|
|
| 199 | +
|
|
| 200 | +function GetSubreportsFiltersDataToCommit() {
|
|
| 201 | + var dataToCommit = new Array();
|
|
| 202 | + if (subreportsFiltersData == null || subreportsFiltersData.length <= 0)
|
|
| 203 | + return dataToCommit;
|
|
| 204 | +
|
|
| 205 | + var globalIndex = 0;
|
|
| 206 | + for (var i = 0; i < subreportsFiltersData.length; i++) {
|
|
| 207 | + for (var index = 0; index < subreportsFiltersData[i].FiltersData.Filters.length; index++) {
|
|
| 208 | + var filter = subreportsFiltersData[i].FiltersData.Filters[index];
|
|
| 209 | + var filterObj = new Object();
|
|
| 210 | + filterObj.Removed = filter.Removed;
|
|
| 211 | + filterObj.Uid = filter.Uid;
|
|
| 212 | + filterObj.GUID = filter.GUID;
|
|
| 213 | + filterObj.IsSubreportFilter = true;
|
|
| 214 | + filterObj.SubreportName = subreportsFiltersData[i].SubreportFullName;
|
|
| 215 | + filterObj.AliasTable = subreportsFiltersData[i].AliasTable;
|
|
| 216 | + if (!filter.Removed)
|
|
| 217 | + filterObj.Values = GetFilterValues(index, subreportsFiltersData[i].FiltersData.Filters, filter.GUID).slice(1);
|
|
| 218 | + dataToCommit[globalIndex] = filterObj;
|
|
| 219 | + globalIndex++;
|
|
| 220 | + }
|
|
| 221 | + }
|
|
| 222 | +
|
|
| 223 | + return dataToCommit;
|
|
| 224 | +}
|
|
| 225 | +
|
|
| 226 | +/**
|
|
| 227 | +* Reload and render filters
|
|
| 228 | +*/
|
|
| 229 | +function s4() {
|
|
| 230 | + return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
|
|
| 231 | +}
|
|
| 232 | +
|
|
| 233 | +function RemoveFilterByUid(uid) {
|
|
| 234 | + for (var index = 0; index < filtersData.length; index++) {
|
|
| 235 | + if (filtersData[index].Uid == uid) {
|
|
| 236 | + filtersData[index].Removed = true;
|
|
| 237 | + for (var i = 0; i < fieldsList.length; i++)
|
|
| 238 | + if (fieldsList[i].DbName == filtersData[index].ColumnName)
|
|
| 239 | + fieldsList[i].FilterOperator = '';
|
|
| 240 | + var filterDiv = document.getElementById(uid);
|
|
| 241 | + if (filterDiv != null)
|
|
| 242 | + filterDiv.style.visibility = 'hidden';
|
|
| 243 | + break;
|
|
| 244 | + }
|
|
| 245 | + }
|
|
| 246 | +
|
|
| 247 | + var updateReportSet = true;
|
|
| 248 | + // Instant Report page
|
|
| 249 | + if (typeof nirConfig != 'undefined' && nirConfig != null)
|
|
| 250 | + updateReportSet = false;
|
|
| 251 | + CommitFiltersData(updateReportSet);
|
|
| 252 | +
|
|
| 253 | + if (typeof updateFields != 'undefined')
|
|
| 254 | + updateFields();
|
|
| 255 | +}
|
|
| 256 | +
|
|
| 257 | +function ShowHideAddFilter() {
|
|
| 258 | + var dNewFilterDiv = document.getElementById('dNewFilter');
|
|
| 259 | + var newFilterColumnSelDiv = document.getElementById('newFilterColumnSel');
|
|
| 260 | + var fuidNewFilterDiv = document.getElementById('fuidNewFilter');
|
|
| 261 | + var isExpanded = fuidNewFilterDiv.getAttribute('expanded') == 'true';
|
|
| 262 | + if (isExpanded) {
|
|
| 263 | + fuidNewFilterDiv.style.width = '30px';
|
|
| 264 | + dNewFilterDiv.innerHTML = '+';
|
|
| 265 | + newFilterColumnSelDiv.style.display = 'none';
|
|
| 266 | + fuidNewFilterDiv.setAttribute('expanded', 'false');
|
|
| 267 | + }
|
|
| 268 | + else {
|
|
| 269 | + fuidNewFilterDiv.style.width = '300px';
|
|
| 270 | + dNewFilterDiv.innerHTML = 'x';
|
|
| 271 | + newFilterColumnSelDiv.style.display = '';
|
|
| 272 | + fuidNewFilterDiv.setAttribute('expanded', 'true');
|
|
| 273 | + }
|
|
| 274 | +}
|
|
| 275 | +
|
|
| 276 | +function AddNewFilterField() {
|
|
| 277 | + var newFilterFieldDropDown = document.getElementById('newFilterFieldDropDown');
|
|
| 278 | + if (newFilterFieldDropDown.value == null || newFilterFieldDropDown.value == '' || newFilterFieldDropDown.value == '...')
|
|
| 279 | + return;
|
|
| 280 | +
|
|
| 281 | + var dupFieldFilter = false;
|
|
| 282 | + for (var i = 0; i < filtersData.length; i++)
|
|
| 283 | + if (filtersData[i].ColumnName == newFilterFieldDropDown.value) {
|
|
| 284 | + dupFieldFilter = true;
|
|
| 285 | + break;
|
|
| 286 | + }
|
|
| 287 | +
|
|
| 288 | + if (!dupFieldFilter)
|
|
| 289 | + for (var i = 0; i < fieldsList.length; i++) {
|
|
| 290 | + if (fieldsList[i].DbName == newFilterFieldDropDown.value)
|
|
| 291 | + fieldsList[i].FilterOperator == 'Equals';
|
|
| 292 | + }
|
|
| 293 | +
|
|
| 294 | + var filterObj = new Object();
|
|
| 295 | + filterObj.Removed = false;
|
|
| 296 | + filterObj.Uid = '';
|
|
| 297 | + filterObj.GUID = '';
|
|
| 298 | + filterObj.Value = null;
|
|
| 299 | + filterObj.Values = null;
|
|
| 300 | + filterObj.Type = 1;
|
|
| 301 | + filterObj.ColumnName = newFilterFieldDropDown.value;
|
|
| 302 | + filterObj.AliasTable = jq$(newFilterFieldDropDown).find('option[value="' + newFilterFieldDropDown.value + '"]').data('alias');
|
|
| 303 | +
|
|
| 304 | + filtersData.push(filterObj);
|
|
| 305 | + CommitFiltersData(false);
|
|
| 306 | + if (typeof updateFields != 'undefined')
|
|
| 307 | + updateFields();
|
|
| 308 | +}
|
|
| 309 | +
|
|
| 310 | +function GenerateNewFilterDropDown() {
|
|
| 311 | + var result = '<select style="width:100%;" id="newFilterFieldDropDown" onchange="AddNewFilterField();">';
|
|
| 312 | + var optionsAdded = false;
|
|
| 313 | + result += '<option value="..." selected="selected">...</option>';
|
|
| 314 | + for (var dsCnt = 0; dsCnt < dataSources.length; dsCnt++) {
|
|
| 315 | + if (dataSources.length > 1)
|
|
| 316 | + result += '<optgroup label="' + dataSources[dsCnt].FriendlyName + '">';
|
|
| 317 | +
|
|
| 318 | + for (var fCnt = 0; fCnt < dataSources[dsCnt].Columns.length; fCnt++) {
|
|
| 319 | + if (!dataSources[dsCnt].Columns[fCnt].FilterHidden) {
|
|
| 320 | + result += '<option value="' + dataSources[dsCnt].Columns[fCnt].DbName + '" data-alias="' + dataSources[dsCnt].JoinAlias + '">' + dataSources[dsCnt].Columns[fCnt].FriendlyName + '</option>';
|
|
| 321 | + optionsAdded = true;
|
|
| 322 | + }
|
|
| 323 | + }
|
|
| 324 | +
|
|
| 325 | + if (dataSources.length > 1)
|
|
| 326 | + result += '</optgroup>';
|
|
| 327 | + }
|
|
| 328 | + result += '</select>';
|
|
| 329 | + if (!optionsAdded)
|
|
| 330 | + return '';
|
|
| 331 | + return result;
|
|
| 332 | +}
|
|
| 333 | +
|
|
| 334 | +function CheckShowAddFilterControls() {
|
|
| 335 | + if (nrvConfig == null || (nrvConfig.AllowNewFiltersInReportViewer && (nrvConfig.ReportIsLocked == null || nrvConfig.ReportIsLocked == false))) {
|
|
| 336 | + var newFilterDataDropDown = GenerateNewFilterDropDown();
|
|
| 337 | + if (newFilterDataDropDown == '')
|
|
| 338 | + return;
|
|
| 339 | +
|
|
| 340 | + var addFilterButton$ = jq$('.fuidNewFilterTemplate').clone();
|
|
| 341 | + addFilterButton$.prop('id', 'fuidNewFilter');
|
|
| 342 | + if (makeFiltersFloat)
|
|
| 343 | + addFilterButton$.css('float', 'left');
|
|
| 344 | + else
|
|
| 345 | + addFilterButton$.css('float', '');
|
|
| 346 | +
|
|
| 347 | + addFilterButton$.find('#newFilterColumnSel').html(newFilterDataDropDown);
|
|
| 348 | + addFilterButton$.show();
|
|
| 349 | +
|
|
| 350 | + jq$('#addFilterControls').html(addFilterButton$);
|
|
| 351 | + jq$('#addFilterControls').show();
|
|
| 352 | + }
|
|
| 353 | +}
|
|
| 354 | +
|
|
| 355 | +function RefreshFilters(returnObj) {
|
|
| 356 | + var htmlFilters = jq$('#htmlFilters');
|
|
| 357 | + htmlFilters.find('.filtersContent').html('');
|
|
| 358 | +
|
|
| 359 | + // Show Filters tab content instead of Loading
|
|
| 360 | + if (htmlFilters.is(':hidden'))
|
|
| 361 | + htmlFilters.show();
|
|
| 362 | + jq$('#tab1 #loadingDiv').hide();
|
|
| 363 | +
|
|
| 364 | + filtersData = returnObj.Filters;
|
|
| 365 | + calendars = new Array();
|
|
| 366 | +
|
|
| 367 | + var controlsIds = new Array();
|
|
| 368 | + var index = 0;
|
|
| 369 | + var hasFilterLogic = false;
|
|
| 370 | + if (returnObj.FilterLogic != null && returnObj.FilterLogic.toString().indexOf('example') == -1)
|
|
| 371 | + hasFilterLogic = true;
|
|
| 372 | + while (index < returnObj.Filters.length) {
|
|
| 373 | + var divsId = 'd' + s4() + s4();
|
|
| 374 | + controlsIds[controlsIds.length] = new Object();
|
|
| 375 | + controlsIds[controlsIds.length - 1].Id = divsId;
|
|
| 376 | + controlsIds[controlsIds.length - 1].filterDesc = returnObj.Filters[index].Description;
|
|
| 377 | +
|
|
| 378 | + var filterContent = GetFilterContent(returnObj.Filters, index, divsId, hasFilterLogic, false);
|
|
| 379 | + htmlFilters.find('.filtersContent').append(filterContent);
|
|
| 380 | + index++;
|
|
| 381 | + }
|
|
| 382 | + var addFilterControl = jq$('.addFilterTemplate').clone();
|
|
| 383 | + addFilterControl.prop('id', 'addFilterControls');
|
|
| 384 | + htmlFilters.find('.filtersContent').append(addFilterControl);
|
|
| 385 | +
|
|
| 386 | + filtersDataObtained = true;
|
|
| 387 | +
|
|
| 388 | + PopulateSubreportsFilters(returnObj);
|
|
| 389 | +
|
|
| 390 | + var dateFormatString = '';
|
|
| 391 | + if (typeof nrvConfig != 'undefined' && nrvConfig != null && typeof nrvConfig.DateFormat != 'undefined' && nrvConfig.DateFormat != null && nrvConfig.DateFormat != '')
|
|
| 392 | + dateFormatString = nrvConfig.DateFormat;
|
|
| 393 | + for (var cc = 0; cc < calendars.length; cc++) {
|
|
| 394 | + var showDatePicker = jq$('#iz-ui-datepicker-div').is(':visible');
|
|
| 395 | + jq$('#iz-ui-datepicker-div').hide();
|
|
| 396 | + jq$(document.getElementById(calendars[cc])).datepicker("destroy");
|
|
| 397 | + if (dateFormatString == '')
|
|
| 398 | + jq$(document.getElementById(calendars[cc])).datepicker();
|
|
| 399 | + else
|
|
| 400 | + jq$(document.getElementById(calendars[cc])).datepicker({ dateFormat: dateFormatString });
|
|
| 401 | + if (showDatePicker)
|
|
| 402 | + jq$(document.getElementById(calendars[cc])).datepicker("show");
|
|
| 403 | + }
|
|
| 404 | +
|
|
| 405 | + htmlFilters.find(".comboboxTreeMultyselect").each(function () {
|
|
| 406 | + var treeControl = jq$(this);
|
|
| 407 | + var index = treeControl.attr("index");
|
|
| 408 | + var possibleValues = returnObj.Filters[index].ExistingValues[0];
|
|
| 409 | + CC_InitializeComboTreeView(treeControl);
|
|
| 410 | + if (possibleValues != null && possibleValues != "")
|
|
| 411 | + possibleValues = possibleValues.substr(2, possibleValues.length - 4);
|
|
| 412 | + CC_TreeUpdateValues(treeControl.parent(), possibleValues.split('", "'));
|
|
| 413 | + });
|
|
| 414 | +
|
|
| 415 | + for (var index = 0; index < controlsIds.length; index++) {
|
|
| 416 | + var labelDiv = document.getElementById(controlsIds[index].Id);
|
|
| 417 | + if (labelDiv == null)
|
|
| 418 | + continue;
|
|
| 419 | + labelDiv.style.width = labelDiv.clientWidth + 'px';
|
|
| 420 | + labelDiv.innerHTML = controlsIds[index].filterDesc;
|
|
| 421 | + }
|
|
| 422 | + if (typeof (switchTabAfterRefreshCycle) === 'boolean' && switchTabAfterRefreshCycle) {
|
|
| 423 | + switchTabAfterRefreshCycle = false;
|
|
| 424 | + if (!jq$(document.getElementById('tab1')).hasClass('active'))
|
|
| 425 | + document.getElementById('tab1a').click();
|
|
| 426 | + }
|
|
| 427 | + makeFiltersFloat = true;
|
|
| 428 | +
|
|
| 429 | + InitAutoComplete();
|
|
| 430 | +
|
|
| 431 | + if (filtersDataObtained && fieldsDataObtained)
|
|
| 432 | + CheckShowAddFilterControls();
|
|
| 433 | +}
|
|
| 434 | +
|
|
| 435 | +function GetFilterContent(filters, index, divsId, hasFilterLogic, isSimpleFilter) {
|
|
| 436 | + var filter = filters[index];
|
|
| 437 | + var filterContent = jq$('.filterViewerTemplate').clone();
|
|
| 438 | + filterContent.removeClass('filterViewerTemplate');
|
|
| 439 | + filterContent.show();
|
|
| 440 | + filterContent.find('.filterInnerContent').prop('id', filter.Uid);
|
|
| 441 | +
|
|
| 442 | + var mouseOverScript = 'this.children[1].style.opacity=0.5; this.children[1].style.backgroundImage= \'url(\\\'\' + this.children[1].getAttribute("data-img") + \'\\\')\'; this.children[2].style.opacity=0.5; this.children[2].style.backgroundImage=\'url(\\\'\' + this.children[2].getAttribute("data-img") + \'\\\')\'; document.getElementById(\''
|
|
| 443 | + + divsId
|
|
| 444 | + + '\').innerHTML = \''
|
|
| 445 | + + filter.Description
|
|
| 446 | + + ' - '
|
|
| 447 | + + filter.OperatorFriendlyName
|
|
| 448 | + + '\';';
|
|
| 449 | + var mouseOutScript = 'for(var index = 1; index < this.children.length; index++){this.children[index].style.backgroundImage=\'none\';}document.getElementById(\''
|
|
| 450 | + + divsId
|
|
| 451 | + + '\').innerHTML = \''
|
|
| 452 | + + filter.Description
|
|
| 453 | + + '\';';
|
|
| 454 | + if (!isSimpleFilter) {
|
|
| 455 | + filterContent.find('.filterHeader').attr('onmouseover', mouseOverScript);
|
|
| 456 | + filterContent.find('.filterHeader').attr('onmouseout', mouseOutScript);
|
|
| 457 | + }
|
|
| 458 | + if (!isSimpleFilter && (typeof nrvConfig == 'undefined' || nrvConfig == null || typeof nrvConfig.ReportIsLocked == 'undefined' || nrvConfig.ReportIsLocked == null || nrvConfig.ReportIsLocked == false)) {
|
|
| 459 | + filterContent.find('.filterRemoveButton').attr('onclick', 'RemoveFilterByUid(\'' + filter.Uid + '\')');
|
|
| 460 | + filterContent.find('.filterPropertiesButton').attr('onclick', 'ShowFieldPropertiesByFullFieldName(\'' + filter.ColumnName + '\', \'' + filter.GUID + '\')');
|
|
| 461 | + }
|
|
| 462 | + else {
|
|
| 463 | + filterContent.find('.filterRemoveButton').hide();
|
|
| 464 | + filterContent.find('.filterPropertiesButton').hide();
|
|
| 465 | + }
|
|
| 466 | + if (isSimpleFilter)
|
|
| 467 | + filterContent.find('.filterTitle, .filterTitleContainer').attr('onmouseover', '');
|
|
| 468 | + filterContent.find('.filterTitle').prop('id', divsId);
|
|
| 469 | + filterContent.find('.filterTitle').html(filter.Description + ' - ' + filter.OperatorFriendlyName);
|
|
| 470 | + var filterInnerContent = GenerateFilterControl(isSimpleFilter ? filter.GUID : index, filter.ControlType, filter.Value, filter.Values, filter.ExistingLabels, filter.ExistingValues, index == filters.length - 1 && !hasFilterLogic);
|
|
| 471 | + filterContent.find('.filterInnerContent').append(filterInnerContent);
|
|
| 472 | +
|
|
| 473 | + if (filter.Parameter != false && filter.AgainstHiddenField)
|
|
| 474 | + filterContent.hide();
|
|
| 475 | +
|
|
| 476 | + return filterContent;
|
|
| 477 | +}
|
|
| 478 | +
|
|
| 479 | +function PopulateSubreportsFilters(returnObj) {
|
|
| 480 | + var subreportFiltersControl = jq$('#htmlFilters .subreportsFiltersTable');
|
|
| 481 | + if (returnObj.SubreportsFilters == null || returnObj.SubreportsFilters.length <= 0) {
|
|
| 482 | + subreportsFiltersData = null;
|
|
| 483 | + subreportFiltersControl.hide();
|
|
| 484 | + return;
|
|
| 485 | + }
|
|
| 486 | + subreportFiltersControl.html('');
|
|
| 487 | + subreportFiltersControl.show();
|
|
| 488 | + for (var i = 0; i < returnObj.SubreportsFilters.length; i++)
|
|
| 489 | + ProcessSubreportFilters(returnObj.SubreportsFilters[i], returnObj.SubreportsFilters.length > 1);
|
|
| 490 | + if (returnObj.SubreportsFilters.length == 1)
|
|
| 491 | + jq$('.subreportsFiltersContent .subreportsTitleText').text(returnObj.SubreportsFilters[0].SubreportFullName);
|
|
| 492 | +
|
|
| 493 | + jq$('.subreportsFiltersContent').show();
|
|
| 494 | + subreportsFiltersData = returnObj.SubreportsFilters;
|
|
| 495 | +}
|
|
| 496 | +
|
|
| 497 | +function ProcessSubreportFilters(subreportFilters, addTitle) {
|
|
| 498 | + if (subreportFilters.FiltersData == null || subreportFilters.FiltersData.Filters == null || subreportFilters.FiltersData.Filters.length == 0)
|
|
| 499 | + return;
|
|
| 500 | +
|
|
| 501 | + var filtersControl = jq$('#htmlFilters .subreportsFiltersTable');
|
|
| 502 | +
|
|
| 503 | + if (addTitle) {
|
|
| 504 | + var subreportTitle = jq$('.subreportTitleTemplate').clone();
|
|
| 505 | + subreportTitle.removeClass('subreportTitleTemplate');
|
|
| 506 | + subreportTitle.find('span').html(subreportFilters.SubreportFullName);
|
|
| 507 | + var subreportTitleRow = jq$('<tr>').append(jq$("<td>").html(subreportTitle));
|
|
| 508 | + filtersControl.append(subreportTitleRow);
|
|
| 509 | + }
|
|
| 510 | +
|
|
| 511 | + var subreportFiltersCell = jq$('<td>');
|
|
| 512 | +
|
|
| 513 | + var hasFilterLogic = false;
|
|
| 514 | + if (subreportFilters.FiltersData.FilterLogic != null && subreportFilters.FiltersData.FilterLogic.toString().indexOf('example') == -1)
|
|
| 515 | + hasFilterLogic = true;
|
|
| 516 | +
|
|
| 517 | + var controlsIds = new Array();
|
|
| 518 | + for (var index = 0; index < subreportFilters.FiltersData.Filters.length; index++) {
|
|
| 519 | + var divsId = 'd' + s4() + s4();
|
|
| 520 | + controlsIds[controlsIds.length] = new Object();
|
|
| 521 | + controlsIds[controlsIds.length - 1].Id = divsId;
|
|
| 522 | + controlsIds[controlsIds.length - 1].filterDesc = subreportFilters.FiltersData.Filters[index].Description;
|
|
| 523 | +
|
|
| 524 | + var filterContent = GetFilterContent(subreportFilters.FiltersData.Filters, index, divsId, hasFilterLogic, true);
|
|
| 525 | +
|
|
| 526 | + subreportFiltersCell.append(filterContent);
|
|
| 527 | + }
|
|
| 528 | + filtersControl.append(jq$('<tr>').append(subreportFiltersCell));
|
|
| 529 | +
|
|
| 530 | + // Process all levels of subreports recursively
|
|
| 531 | + if (subreportFilters.FiltersData.SubreportsFilters != null && subreportFilters.FiltersData.SubreportsFilters.length > 0)
|
|
| 532 | + for (var i = 0; i < subreportFilters.FiltersData.SubreportsFilters.length; i++)
|
|
| 533 | + ProcessSubreportFilters(subreportFilters.FiltersData.SubreportsFilters[i]);
|
|
| 534 | +}
|
|
| 535 | +
|
|
| 536 | +function ToggleSubreportsFiltersControl() {
|
|
| 537 | + jq$('.subreportsFiltersTable').toggle('slide', { direction: 'up' });
|
|
| 538 | + jq$('.subreportsCollapse').toggle();
|
|
| 539 | + jq$('.subreportsExpand').toggle();
|
|
| 540 | +}
|
|
| 541 | +
|
|
| 542 | +function CascadingFiltersChanged(returnObj, id) {
|
|
| 543 | + if (id != ('refreshcascadingfilters-' + refreshFiltersLastGUID) || returnObj == null)
|
|
| 544 | + return;
|
|
| 545 | + RefreshFilters(returnObj);
|
|
| 546 | +}
|
|
| 547 | +
|
|
| 548 | +function FiltersDataSet(returnObj, id) {
|
|
| 549 | + if (id != 'setfiltersdata' || returnObj == null)
|
|
| 550 | + return;
|
|
| 551 | + if (returnObj.Value != 'OK')
|
|
| 552 | + return;
|
|
| 553 | + GetFiltersData();
|
|
| 554 | + GetRenderedReportSet(true);
|
|
| 555 | + if (typeof GetDatasourcesList != 'undefined')
|
|
| 556 | + GetDatasourcesList();
|
|
| 557 | +}
|
|
| 558 | +
|
|
| 559 | +function HidePopupDialog(updateState) {
|
|
| 560 | + if (updateState) {
|
|
| 561 | + var filterIndex = document.getElementById('popupDlgFilterIndex').value;
|
|
| 562 | + var newVal = '';
|
|
| 563 | + var cnt6 = 0;
|
|
| 564 | + var cb = document.getElementById('ndbfc' + filterIndex + '_cb' + cnt6);
|
|
| 565 | + while (cb != null) {
|
|
| 566 | + if (cb.checked) {
|
|
| 567 | + if (newVal.length > 1)
|
|
| 568 | + newVal += ',';
|
|
| 569 | + newVal += cb.value;
|
|
| 570 | + }
|
|
| 571 | + cnt6++;
|
|
| 572 | + cb = document.getElementById('ndbfc' + filterIndex + '_cb' + cnt6);
|
|
| 573 | + }
|
|
| 574 | + var popupDlgValuesContainer = document.getElementById('ndbfc' + filterIndex);
|
|
| 575 | + popupDlgValuesContainer.value = newVal;
|
|
| 576 | + }
|
|
| 577 | + var popupEsDialog = document.getElementById('popupEsDialog');
|
|
| 578 | + popupEsDialog.style.display = 'none';
|
|
| 579 | + if (updateState) {
|
|
| 580 | + CommitFiltersData(false);
|
|
| 581 | + }
|
|
| 582 | +}
|
|
| 583 | +
|
|
| 584 | +function ShowEqualsPopupDialog(filterInd) {
|
|
| 585 | + var filter = filtersData[filterInd];
|
|
| 586 | + var valueInput = document.getElementById('ndbfc' + filterInd);
|
|
| 587 | + var valuesSet6 = valueInput.value.split(',');
|
|
| 588 | + var epdHtml = '<table width="100%"><tr>';
|
|
| 589 | + var inLine = 0;
|
|
| 590 | + var rowsNum = 1;
|
|
| 591 | + var ecbCnt = 0;
|
|
| 592 | + for (var evCnt = 0; evCnt < filter.ExistingValues.length; evCnt++) {
|
|
| 593 | + if (filter.ExistingValues[evCnt] == '...') {
|
|
| 594 | + continue;
|
|
| 595 | + }
|
|
| 596 | + var checked = '';
|
|
| 597 | + for (var cCnt = 0; cCnt < valuesSet6.length; cCnt++) {
|
|
| 598 | + if (valuesSet6[cCnt] == filter.ExistingValues[evCnt]) {
|
|
| 599 | + checked = 'checked = "checked"';
|
|
| 600 | + }
|
|
| 601 | + }
|
|
| 602 | + epdHtml += '<td width="33%" align="left"><input type="checkbox" id="ndbfc' + filterInd + '_cb' + ecbCnt + '" ' + checked + ' value="' + filter.ExistingValues[evCnt] + '" /> ' + filter.ExistingLabels[evCnt] + '</td>';
|
|
| 603 | + ecbCnt++;
|
|
| 604 | + inLine++;
|
|
| 605 | + if (inLine >= 3) {
|
|
| 606 | + rowsNum++;
|
|
| 607 | + inLine = 0;
|
|
| 608 | + if (evCnt < filter.ExistingValues.length - 1) {
|
|
| 609 | + epdHtml += '</tr><tr>';
|
|
| 610 | + }
|
|
| 611 | + }
|
|
| 612 | + }
|
|
| 613 | + epdHtml += '<input type="hidden" id="popupDlgFilterIndex" value="' + filterInd + '" />';
|
|
| 614 | + var epdContent = document.getElementById('epdContent');
|
|
| 615 | + epdContent.innerHTML = epdHtml;
|
|
| 616 | + var popupEsDialog = document.getElementById('popupEsDialog');
|
|
| 617 | + var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
|
|
| 618 | + popupEsDialog.style.height = windowHeight + 'px';
|
|
| 619 | + var epdHeight = rowsNum * 28 + 110;
|
|
| 620 | + var padTop = ((windowHeight - epdHeight) / 2);
|
|
| 621 | + if (padTop < 140) {
|
|
| 622 | + padTop = 140;
|
|
| 623 | + }
|
|
| 624 | + popupEsDialog.style.paddingTop = padTop + 'px';
|
|
| 625 | + popupEsDialog.style.display = '';
|
|
| 626 | +}
|
|
| 627 | +
|
|
| 628 | +function GenerateFilterControl(index, cType, value, values, existingLabels, existingValues, isLastFilter) {
|
|
| 629 | + var notRefreshFilters = isLastFilter || nrvConfig && nrvConfig.CascadeFilterValues == false;
|
|
| 630 | + var onChangeCmd = notRefreshFilters ? '' : 'onchange="CommitFiltersData(false);"';
|
|
| 631 | + //var onKeyUpCmd = 'onkeyup="CommitFiltersData(false);"';
|
|
| 632 | + var onKeyUpCmd = '';
|
|
| 633 | + var result = '';
|
|
| 634 | + switch (cType) {
|
|
| 635 | + case 1:
|
|
| 636 | + result = '<input style="width:99%;" type="text" id="ndbfc' + index + '" value="' + value.replaceAll('"', """) + '" ' + onKeyUpCmd + ' />';
|
|
| 637 | + break;
|
|
| 638 | + case 2:
|
|
| 639 | + result = '<input style="width:99%;" type="text" id="ndbfc' + index + '_l" value="' + values[0].replaceAll('"', """) + '" ' + onKeyUpCmd + ' />';
|
|
| 640 | + result += '<input style="width:99%;" type="text" id="ndbfc' + index + '_r" value="' + values[1].replaceAll('"', """) + '" ' + onKeyUpCmd + ' />';
|
|
| 641 | + break;
|
|
| 642 | + case 3:
|
|
| 643 | + result += '<select style="width:100%;" id="ndbfc' + index + '" ' + onChangeCmd + '>';
|
|
| 644 | + var groupOpened = false;
|
|
| 645 | + for (var cnt3 = 0; cnt3 < existingValues.length; cnt3++) {
|
|
| 646 | + var selected3 = '';
|
|
| 647 | + if (existingValues[cnt3] == value)
|
|
| 648 | + selected3 = 'selected="selected"';
|
|
| 649 | + if (existingValues[cnt3] == null) {
|
|
| 650 | + if (groupOpened)
|
|
| 651 | + result += '</optgroup>';
|
|
| 652 | + result += '<optgroup label="' + existingLabels[cnt3] + '">';
|
|
| 653 | + groupOpened = true;
|
|
| 654 | + } else
|
|
| 655 | + result += '<option value="' + existingValues[cnt3].replace(/"/g, '"') + '" ' + selected3 + '>' + existingLabels[cnt3] + '</option>';
|
|
| 656 | + }
|
|
| 657 | + if (groupOpened)
|
|
| 658 | + result += '</optgroup>';
|
|
| 659 | + result += '</select>';
|
|
| 660 | + break;
|
|
| 661 | + case 4:
|
|
| 662 | + result += '<select style="width:100%" id="ndbfc' + index + '" ' + onChangeCmd + '>';
|
|
| 663 | + for (var cnt4 = 0; cnt4 < existingValues.length; cnt4++) {
|
|
| 664 | + var selected4 = '';
|
|
| 665 | + if (existingValues[cnt4] == value)
|
|
| 666 | + selected4 = 'selected="selected"';
|
|
| 667 | + result += '<option value="' + existingValues[cnt4].replace(/"/g, '"') + '" ' + selected4 + '>' + existingLabels[cnt4] + '</option>';
|
|
| 668 | + }
|
|
| 669 | + result += '</select>';
|
|
| 670 | + break;
|
|
| 671 | + case 5:
|
|
| 672 | + onChangeCmd = notRefreshFilters ? '' : 'onchange="setTimeout(function(){CommitFiltersData(false);},401);"';
|
|
| 673 | + result += '<input type="text" ' + onChangeCmd + ' value="' + values[0].replaceAll('"', """) + '" style="width:248px" id="ndbfc' + index + '_1" />';
|
|
| 674 | + calendars[calendars.length] = 'ndbfc' + index + '_1';
|
|
| 675 | + result += '<img onclick="javascript: if (showingC) {return;} showingC = true; setTimeout(function() {document.getElementById(\'ndbfc' + index + '_1\').focus(); setTimeout(function(){showingC = false;jq$(\'#iz-ui-datepicker-div\').css(\'z-index\', \'2000\');}, 500);}, 500); " style="cursor:pointer;position:relative;top:4px;" src="' + urlSettings.urlRsPage + '?image=calendar_icon.png">';
|
|
| 676 | + result += '<br />';
|
|
| 677 | + result += '<input type="text" ' + onChangeCmd + ' value="' + values[1].replaceAll('"', """) + '" style="width:248px" id="ndbfc' + index + '_2" />';
|
|
| 678 | + calendars[calendars.length] = 'ndbfc' + index + '_2';
|
|
| 679 | + result += '<img onclick="javascript: if (showingC) {return;} showingC = true; setTimeout(function() {document.getElementById(\'ndbfc' + index + '_2\').focus(); setTimeout(function(){showingC = false;jq$(\'#iz-ui-datepicker-div\').css(\'z-index\', \'2000\');}, 500);}, 500); " style="cursor:pointer;position:relative;top:4px;" src="' + urlSettings.urlRsPage + '?image=calendar_icon.png">';
|
|
| 680 | + break;
|
|
| 681 | + case 6:
|
|
| 682 | + result += '<input type="button" style="height:30px;width:300px;background-color:LightGray;border:1px solid DarkGray" onclick="ShowEqualsPopupDialog(' + index + ');" value="...">';
|
|
| 683 | + result += '<input type="hidden" id="ndbfc' + index + '" value="' + value + '" />';
|
|
| 684 | + break;
|
|
| 685 | + case 7:
|
|
| 686 | + result += '<textarea style="width:99%;" rows="2" id="ndbfc' + index + '" ' + onKeyUpCmd + '>' + value + '</textarea>';
|
|
| 687 | + break;
|
|
| 688 | + case 8:
|
|
| 689 | + result += '<div id="ndbfc' + index + '" class="saveScroll" style="padding-left:8px; width:96%; overflow: auto; max-height: 100px;background-color: white;border: 1px solid #A5A5A5;">';
|
|
| 690 | + var valuesSet8 = value.split(',');
|
|
| 691 | + for (var cnt8 = 0; cnt8 < existingValues.length; cnt8++) {
|
|
| 692 | + var checked8 = '';
|
|
| 693 | + for (var subCnt8 = 0; subCnt8 < valuesSet8.length; subCnt8++) {
|
|
| 694 | + if (existingValues[cnt8] == valuesSet8[subCnt8]) {
|
|
| 695 | + checked8 = ' checked="checked"';
|
|
| 696 | + break;
|
|
| 697 | + }
|
|
| 698 | + }
|
|
| 699 | + if (checked8 != '')
|
|
| 700 | + result += '<nobr><input type="checkbox" id="ndbfc' + index + '_cb' + cnt8 + '" ' + onChangeCmd + ' value="' + existingValues[cnt8].replace(/"/g, '"') + '"' + checked8 + ' />' + existingLabels[cnt8] + '</nobr><br>';
|
|
| 701 | + }
|
|
| 702 | + for (var cnt8 = 0; cnt8 < existingValues.length; cnt8++) {
|
|
| 703 | + var checked8 = '';
|
|
| 704 | + for (var subCnt8 = 0; subCnt8 < valuesSet8.length; subCnt8++) {
|
|
| 705 | + if (existingValues[cnt8] == valuesSet8[subCnt8]) {
|
|
| 706 | + checked8 = ' checked="checked"';
|
|
| 707 | + break;
|
|
| 708 | + }
|
|
| 709 | + }
|
|
| 710 | + if (checked8 == '')
|
|
| 711 | + result += '<nobr><input type="checkbox" id="ndbfc' + index + '_cb' + cnt8 + '" ' + onChangeCmd + ' value="' + existingValues[cnt8].replace(/"/g, '"') + '"' + checked8 + ' />' + existingLabels[cnt8] + '</nobr><br>';
|
|
| 712 | + }
|
|
| 713 | + result += '</div>';
|
|
| 714 | + break;
|
|
| 715 | + case 9:
|
|
| 716 | + onChangeCmd = notRefreshFilters ? '' : 'onchange="setTimeout(function(){CommitFiltersData(false);},401);"';
|
|
| 717 | + result += '<input type="text" ' + onChangeCmd + ' value="' + value.replaceAll('"', """) + '" style="width:248px" id="ndbfc' + index + '" />';
|
|
| 718 | + calendars[calendars.length] = 'ndbfc' + index;
|
|
| 719 | + result += '<img onclick="javascript: if (showingC) {return;} showingC = true; setTimeout(function() {document.getElementById(\'ndbfc' + index + '\').focus(); setTimeout(function(){showingC = false;jq$(\'#iz-ui-datepicker-div\').css(\'z-index\', \'2000\');}, 500);}, 500); " style="cursor:pointer;position:relative;top:4px;" src="rs.aspx?image=calendar_icon.png">';
|
|
| 720 | + break;
|
|
| 721 | + case 10:
|
|
| 722 | + result += '<select class="saveScroll" style="width:100%" size="5" multiple="" id="ndbfc' + index + '" ' + onChangeCmd + '>';
|
|
| 723 | + var valuesSet10 = value.split(',');
|
|
| 724 | + for (var cnt10 = 0; cnt10 < existingValues.length; cnt10++) {
|
|
| 725 | + var selected10 = '';
|
|
| 726 | + for (var subCnt = 0; subCnt < valuesSet10.length; subCnt++) {
|
|
| 727 | + if (existingValues[cnt10] == valuesSet10[subCnt]) {
|
|
| 728 | + selected10 = 'selected="selected"';
|
|
| 729 | + break;
|
|
| 730 | + }
|
|
| 731 | + }
|
|
| 732 | + result += '<option value="' + existingValues[cnt10].replace(/"/g, '"') + '" ' + selected10 + '>' + existingLabels[cnt10] + '</option>';
|
|
| 733 | + }
|
|
| 734 | + result += '</select>';
|
|
| 735 | + break;
|
|
| 736 | + case 11:
|
|
| 737 | + result += '<div style="display: none;" visibilitymode="1"><input type="text" id="ndbfc' + index + '" value="' + value.replaceAll('"', """) + '"/></div>';
|
|
| 738 | + result += '<div class="comboboxTreeMultyselect" index=' + index + '></div>';
|
|
| 739 | + break;
|
|
| 740 | + case 100:
|
|
| 741 | + result = '<input style="width:99%;" type="text" name="autocomplete-filter" id="ndbfc' + index + '" value="' + value.replaceAll('"', """) + '" ' + onKeyUpCmd + ' />';
|
|
| 742 | + break;
|
|
| 743 | + default:
|
|
| 744 | + result = '';
|
|
| 745 | + }
|
|
| 746 | + return result;
|
|
| 747 | +}
|
|
| 748 | +
|
|
| 749 | +/**
|
|
| 750 | +* Load filters
|
|
| 751 | +*/
|
|
| 752 | +function GetFiltersData() {
|
|
| 753 | + var requestString = 'wscmd=getfiltersdata';
|
|
| 754 | + AjaxRequest(urlSettings.urlRsPage, requestString, GotFiltersData, null, 'getfiltersdata');
|
|
| 755 | +}
|
|
| 756 | +
|
|
| 757 | +function GotFiltersData(returnObj, id) {
|
|
| 758 | + if (id != 'getfiltersdata' || returnObj == null)
|
|
| 759 | + return;
|
|
| 760 | + RefreshFilters(returnObj);
|
|
| 761 | + jq$('#htmlFilters :input').prop('disabled', false);
|
|
| 762 | +}
|
|
| 763 | +
|
|
| 764 | +CC_InitializeComboTreeView = function (mainControl) {
|
|
| 765 | + mainControl.addClass("comboboxTreeMultyselect");
|
|
| 766 | + mainControl.each(function () {
|
|
| 767 | + var currentControl = jq$(this);
|
|
| 768 | + currentControl.empty();
|
|
| 769 | +
|
|
| 770 | + var combobox = jq$(document.createElement("div")).addClass("textArea");
|
|
| 771 | + currentControl.append(combobox);
|
|
| 772 | +
|
|
| 773 | + var selectedValues = jq$(document.createElement("div")).addClass("selectedValues").addClass("hiddenTree");
|
|
| 774 | + currentControl.append(selectedValues);
|
|
| 775 | +
|
|
| 776 | + var tree = jq$(document.createElement("div")).addClass("tree").addClass("hiddenTree");
|
|
| 777 | + currentControl.append(tree);
|
|
| 778 | +
|
|
| 779 | + var search = jq$(document.createElement("input")).addClass("search");
|
|
| 780 | + combobox.append(search);
|
|
| 781 | +
|
|
| 782 | + combobox.click(function () {
|
|
| 783 | + search.focus();
|
|
| 784 | + });
|
|
| 785 | +
|
|
| 786 | + search.keyup(function () {
|
|
| 787 | + var realText = search.val();
|
|
| 788 | + var text = realText.toLowerCase();
|
|
| 789 | +
|
|
| 790 | + var list = new Array();
|
|
| 791 | + tree.find(".node").each(function () {
|
|
| 792 | + var node = jq$(this);
|
|
| 793 | + if (node.hasClass("haschild")) {
|
|
| 794 | + node.addClass("searchHide");
|
|
| 795 | + }
|
|
| 796 | + else {
|
|
| 797 | + var val = node.attr("value").toLowerCase();
|
|
| 798 | + var index = val.indexOf(text);
|
|
| 799 | + if (index > -1) {
|
|
| 800 | + list.push(node);
|
|
| 801 | + }
|
|
| 802 | + else {
|
|
| 803 | + node.addClass("searchHide");
|
|
| 804 | + }
|
|
| 805 | + }
|
|
| 806 | + });
|
|
| 807 | + for (var i = 0; i < list.length; i++) {
|
|
| 808 | + var parent = list[i].parent();
|
|
| 809 | + while (!parent.hasClass("tree")) {
|
|
| 810 | + parent.removeClass("searchHide");
|
|
| 811 | + parent = parent.parent();
|
|
| 812 | + }
|
|
| 813 | + }
|
|
| 814 | +
|
|
| 815 | + tree.find(".hiddenBySearch").each(function () {
|
|
| 816 | + var node = jq$(this);
|
|
| 817 | + if (!node.hasClass("searchHide"))
|
|
| 818 | + node.removeClass("hiddenBySearch");
|
|
| 819 | + });
|
|
| 820 | +
|
|
| 821 | + tree.find(".searchHide").addClass("hiddenBySearch").removeClass("searchHide");
|
|
| 822 | +
|
|
| 823 | + tree.find(".node").each(function () {
|
|
| 824 | + var node = jq$(this);
|
|
| 825 | + if (!node.hasClass("hiddenBySearch")) {
|
|
| 826 | + var textToReplace = node.attr("text");
|
|
| 827 | + var resultText = textToReplace;
|
|
| 828 | + var lowerText = textToReplace.toLowerCase();
|
|
| 829 | +
|
|
| 830 | + var index = lowerText.indexOf(text);
|
|
| 831 | + if (index > -1) {
|
|
| 832 | + resultText = textToReplace.substring(0, index);
|
|
| 833 | + resultText += "<span class='highlight'>" + textToReplace.substring(index, index + realText.length) + "</span>";
|
|
| 834 | + resultText += textToReplace.substring(index + realText.length);
|
|
| 835 | + }
|
|
| 836 | + node.find("> span.text").html(resultText);
|
|
| 837 | + }
|
|
| 838 | + else {
|
|
| 839 | + node.find("> span.text").html(node.attr("text"));
|
|
| 840 | + }
|
|
| 841 | + });
|
|
| 842 | +
|
|
| 843 | +
|
|
| 844 | + if (tree.hasClass("hiddenTree"))
|
|
| 845 | + tree.removeClass("hiddenTree");
|
|
| 846 | +
|
|
| 847 | + });
|
|
| 848 | +
|
|
| 849 | +
|
|
| 850 | + var showHide = jq$(document.createElement("div")).addClass("showHide");
|
|
| 851 | + showHide.click(function () {
|
|
| 852 | + CC_ClickShowHide(tree);
|
|
| 853 | + });
|
|
| 854 | + combobox.append(showHide);
|
|
| 855 | +
|
|
| 856 | + jq$(document).click(function (e) {
|
|
| 857 | + var target = jq$(e.target);
|
|
| 858 | + if (target.hasClass("chunkX")) return;
|
|
| 859 | + if (target.closest(tree).length != 0) return;
|
|
| 860 | + if (target.closest(combobox).length != 0) return;
|
|
| 861 | + tree.addClass("hiddenTree");
|
|
| 862 | + });
|
|
| 863 | + });
|
|
| 864 | +};
|
|
| 865 | +
|
|
| 866 | +var CC_appendItem = function (node, itemText, prevText, tree, selectedValues, row) {
|
|
| 867 | + var itemParts = itemText.split('"-"');
|
|
| 868 | + itemText = itemParts[0];
|
|
| 869 | + var itemValue = itemParts.length > 1 ? itemParts[1].substring(0, itemParts[1].length) : itemText;
|
|
| 870 | + var index = itemText.indexOf("|");
|
|
| 871 | + var text = itemText;
|
|
| 872 | + var subNode = "";
|
|
| 873 | + if (index > -1) {
|
|
| 874 | + text = itemText.substr(0, index);
|
|
| 875 | + subNode = itemText.substr(index + 1);
|
|
| 876 | + }
|
|
| 877 | +
|
|
| 878 | + var value = text;
|
|
| 879 | + if (prevText != "")
|
|
| 880 | + value = prevText + "|" + value;
|
|
| 881 | +
|
|
| 882 | + var newNode = node.find("> .node[value='" + value.replace(/'/g, "''") + "']");
|
|
| 883 | + if (newNode.length == 0) {
|
|
| 884 | + newNode = jq$(document.createElement("div")).addClass("node").attr("value", value).attr("text", text).attr("text-value", itemValue);
|
|
| 885 | + if (subNode != "")
|
|
| 886 | + newNode.addClass("haschild");
|
|
| 887 | + newNode.html('<div class="collapse" ></div><input type="checkbox" class="checkbox"/><span class="text">' + text + "</span>");
|
|
| 888 | + node.append(newNode);
|
|
| 889 | +
|
|
| 890 | + newNode.find("> .collapse").click(function () {
|
|
| 891 | + if (newNode.hasClass("haschild")) {
|
|
| 892 | + if (newNode.hasClass("collapsed")) {
|
|
| 893 | + newNode.removeClass("collapsed");
|
|
| 894 | + } else {
|
|
| 895 | + newNode.addClass("collapsed");
|
|
| 896 | + }
|
|
| 897 | + }
|
|
| 898 | + });
|
|
| 899 | +
|
|
| 900 | + newNode.find("> .checkbox").click(function () {
|
|
| 901 | + var isChecked = jq$(this).is(':checked');
|
|
| 902 | + CC_CheckUnchekChild(newNode.find("> .node"), isChecked);
|
|
| 903 | + if (!isChecked) {
|
|
| 904 | + var parent = newNode.parent();
|
|
| 905 | + while (parent.hasClass("node")) {
|
|
| 906 | + parent.find("> .checkbox").prop('checked', isChecked);
|
|
| 907 | + parent = parent.parent();
|
|
| 908 | + }
|
|
| 909 | + }
|
|
| 910 | + CC_CheckStatusWasChanged(selectedValues, tree.find("> .node"), tree, row);
|
|
| 911 | + });
|
|
| 912 | +
|
|
| 913 | + }
|
|
| 914 | +
|
|
| 915 | + if (subNode != "") {
|
|
| 916 | + CC_appendItem(newNode, subNode + "\"-\"" + itemValue, value, tree, selectedValues, row);
|
|
| 917 | + }
|
|
| 918 | +
|
|
| 919 | +};
|
|
| 920 | +
|
|
| 921 | +CC_CheckUnchekChild = function (element, check) {
|
|
| 922 | + element.find("> .checkbox").prop('checked', check);
|
|
| 923 | + element.find("> .node").each(function () {
|
|
| 924 | + CC_CheckUnchekChild(jq$(this), check);
|
|
| 925 | + });
|
|
| 926 | +};
|
|
| 927 | +
|
|
| 928 | +CC_CheckStatusWasChanged = function (selectedValues, nodes, tree, row) {
|
|
| 929 | + selectedValues.empty();
|
|
| 930 | + nodes.each(function () {
|
|
| 931 | + CC_FillCombobox(selectedValues, jq$(this), row);
|
|
| 932 | + });
|
|
| 933 | +
|
|
| 934 | + var strVal = "";
|
|
| 935 | + selectedValues.find(".cValid").each(function () {
|
|
| 936 | + strVal += ", " + jq$(this).attr("value");
|
|
| 937 | + });
|
|
| 938 | + strVal = strVal.substr(2);
|
|
| 939 | + if (strVal == "")
|
|
| 940 | + selectedValues.addClass("hiddenTree");
|
|
| 941 | + else
|
|
| 942 | + selectedValues.removeClass("hiddenTree");
|
|
| 943 | +
|
|
| 944 | + jq$(row).find("div[visibilitymode=1] input").attr("value", strVal);
|
|
| 945 | +};
|
|
| 946 | +
|
|
| 947 | +CC_ClickShowHide = function (tree) {
|
|
| 948 | + if (tree.hasClass("hiddenTree"))
|
|
| 949 | + tree.removeClass("hiddenTree");
|
|
| 950 | + else
|
|
| 951 | + tree.addClass("hiddenTree");
|
|
| 952 | +};
|
|
| 953 | +
|
|
| 954 | +CC_FillCombobox = function (selectedValues, node, row) {
|
|
| 955 | + if (node.find("> .checkbox").is(':checked')) {
|
|
| 956 | +
|
|
| 957 | + var hasChild = node.hasClass("haschild");
|
|
| 958 | +
|
|
| 959 | + var text = node.attr("text");
|
|
| 960 | + var val = node.attr("value");
|
|
| 961 | +
|
|
| 962 | + if (text == null || text == "" || val == "" || val == null)
|
|
| 963 | + return;
|
|
| 964 | +
|
|
| 965 | +
|
|
| 966 | + var cValid = jq$(document.createElement("a"));
|
|
| 967 | +
|
|
| 968 | + var displayTesxt = val.replace(/\|/g, "\\");
|
|
| 969 | + if (displayTesxt.length > 50) {
|
|
| 970 | + var newText = "...\\" + text;
|
|
| 971 | + var len = newText.length;
|
|
| 972 | + var i = 0;
|
|
| 973 | + var s = "";
|
|
| 974 | + while (len < 40) {
|
|
| 975 | + s += displayTesxt[i];
|
|
| 976 | + i++;
|
|
| 977 | + len++;
|
|
| 978 | + }
|
|
| 979 | + displayTesxt = s + newText;
|
|
| 980 | + }
|
|
| 981 | +
|
|
| 982 | + if (hasChild)
|
|
| 983 | + displayTesxt += "\\";
|
|
| 984 | +
|
|
| 985 | + cValid.addClass("cValid");
|
|
| 986 | + cValid.attr("value", val);
|
|
| 987 | + var responseServerUrl = 'rs.aspx?';
|
|
| 988 | + // From ReportViewer.js
|
|
| 989 | + if (typeof nrvConfig != 'undefined')
|
|
| 990 | + responseServerUrl = nrvConfig.ResponseServerUrl + nrvConfig.serverDelimiter;
|
|
| 991 | + cValid.html('<nobr>' + displayTesxt + '<img src="' + responseServerUrl + 'image=icon-blue-x.gif" class="chunkX"></nobr>');
|
|
| 992 | + selectedValues.append(cValid);
|
|
| 993 | + cValid.find(".chunkX").click(function () {
|
|
| 994 | + cValid.remove();
|
|
| 995 | + node.find("> .checkbox").prop("checked", false);
|
|
| 996 | + CC_CheckUnchekChild(node, false);
|
|
| 997 | +
|
|
| 998 | + var strVal = "";
|
|
| 999 | + selectedValues.find(".cValid").each(function () {
|
|
| 1000 | + strVal += ", " + jq$(this).attr("value");
|
|
| 1001 | + });
|
|
| 1002 | + strVal = strVal.substr(2);
|
|
| 1003 | + jq$(row).find("div[visibilitymode=1] input").attr("value", strVal);
|
|
| 1004 | +
|
|
| 1005 | + if (strVal == "")
|
|
| 1006 | + selectedValues.addClass("hiddenTree");
|
|
| 1007 | + else
|
|
| 1008 | + selectedValues.removeClass("hiddenTree");
|
|
| 1009 | + });
|
|
| 1010 | + } else {
|
|
| 1011 | + node.find("> .node").each(function () {
|
|
| 1012 | + CC_FillCombobox(selectedValues, jq$(this), row);
|
|
| 1013 | + });
|
|
| 1014 | + }
|
|
| 1015 | +};
|
|
| 1016 | +
|
|
| 1017 | +CC_TreeUpdateValues = function (row, values) {
|
|
| 1018 | +
|
|
| 1019 | + var selectedValues = jq$(row).find("div[visibilitymode=1] input").attr("value");
|
|
| 1020 | +
|
|
| 1021 | + var tree = jq$(row).find(".comboboxTreeMultyselect .tree");
|
|
| 1022 | + var selectedValuesControl = jq$(row).find(".comboboxTreeMultyselect .selectedValues");
|
|
| 1023 | + tree.empty();
|
|
| 1024 | + for (var i = 0; i < values.length; i++) {
|
|
| 1025 | + CC_appendItem(tree, values[i], "", tree, selectedValuesControl, row);
|
|
| 1026 | + }
|
|
| 1027 | +
|
|
| 1028 | + var valueList = selectedValues.split(", ");
|
|
| 1029 | + for (var i = 0; i < valueList.length; i++)
|
|
| 1030 | + tree.find('.node[value="' + valueList[i] + '"]').each(function () {
|
|
| 1031 | + CC_CheckUnchekChild(jq$(this), true);
|
|
| 1032 | + });
|
|
| 1033 | + CC_CheckStatusWasChanged(selectedValuesControl, tree.find("> .node"), tree, row);
|
|
| 1034 | +};
|
|
| 1035 | +
|
|
| 1036 | +function InitAutoComplete() {
|
|
| 1037 | + var autocompleteElements = jq$('input[name="autocomplete-filter"]');
|
|
| 1038 | + if (autocompleteElements.length == 0 || (jq$.browser.msie && 1 * jq$.browser.version < 9))
|
|
| 1039 | + return;
|
|
| 1040 | + for (var i = 0; i < autocompleteElements.length; i++) {
|
|
| 1041 | + var currInput = autocompleteElements[i];
|
|
| 1042 | + jq$(currInput).autocomplete({
|
|
| 1043 | + source: function (req, responeFunction) {
|
|
| 1044 | + var possibleText = CC_extractLast(req.term);
|
|
| 1045 | + var filterIndex = jq$(this.element).attr('id').toString().replace('ndbfc', '');
|
|
| 1046 | + var fullColumnName = filtersData[filterIndex].ColumnName;
|
|
| 1047 | + var cmd = '&possibleValue=' + possibleText.replace('&', '%26');
|
|
| 1048 | + EBC_LoadData('ExistentValuesList', 'columnName=' + fullColumnName + cmd, null, true, function (responseResult) {
|
|
| 1049 | + var options = jq$(responseResult);
|
|
| 1050 | + var cnt = options.length;
|
|
| 1051 | + var result = new Array();
|
|
| 1052 | + for (var i = 0; i < cnt; i++) {
|
|
| 1053 | + var text = options[i].value;
|
|
| 1054 | + if (text != null && text != "" && text != "...")
|
|
| 1055 | + result.push(text);
|
|
| 1056 | + }
|
|
| 1057 | + responeFunction(result);
|
|
| 1058 | + });
|
|
| 1059 | + },
|
|
| 1060 | + search: function () {
|
|
| 1061 | + var term = CC_extractLast(this.value);
|
|
| 1062 | + if (term.length < 1) {
|
|
| 1063 | + return false;
|
|
| 1064 | + }
|
|
| 1065 | + },
|
|
| 1066 | + focus: function () {
|
|
| 1067 | + return false;
|
|
| 1068 | + },
|
|
| 1069 | + select: function (event, ui) {
|
|
| 1070 | + var terms = CC_split(this.value);
|
|
| 1071 | + terms.pop();
|
|
| 1072 | + terms.push(ui.item.value);
|
|
| 1073 | + this.value = terms.join(", ");
|
|
| 1074 | + return false;
|
|
| 1075 | + }
|
|
| 1076 | + });
|
|
| 1077 | + }
|
|
| 1078 | +}
|
|
| 1079 | +
|
|
| 1080 | +function CC_split(val) {
|
|
| 1081 | + return val.split(/,\s*/);
|
|
| 1082 | +}
|
|
| 1083 | +
|
|
| 1084 | +function CC_extractLast(term) {
|
|
| 1085 | + return CC_split(term).pop();
|
|
| 1086 | +} |
|
| ... | ... | \ No newline at end of file |