jQWidgets Forums
Forum Replies Created
-
Author
-
I got the solution
Both methods are:
function createNestedGrid(){ nestedGrids = new Array(); var container = $('#gridOrders); var result = {"orderDetail":{"data":[{"id":"1","idOrder":"1","dateCreation":"2013-09-25 00:00:00","idSellType":"1","_idSellType":"NUEVO","idProduct":"3","_idProduct":"Foo Pack example with large name","quantity":"1","idStatus":"26","_idStatus":"NUEVA"}],"structure":{"id":{"name":"id","type":"int","null":"NO","key":"","default":"0","extra":"","length":"11","relationTable":null,"relationField":null,"validators":["int",["max","11"]]},"idOrder":{"name":"idOrder","type":"int","null":"NO","key":"","default":null,"extra":"","length":"11","relationTable":null,"relationField":null,"validators":["req","int",["max","11"]]},"dateCreation":{"name":"dateCreation","type":"timestamp","null":"YES","key":"","default":null,"extra":"","length":0,"relationTable":null,"relationField":null,"validators":["str"]},"idSellType":{"name":"idSellType","type":"int","null":"NO","key":"","default":"1","extra":"","length":"1","relationTable":null,"relationField":null,"validators":["int",["max","1"]]},"_idSellType":{"name":"_idSellType","type":"varchar","null":"YES","key":"","default":null,"extra":"","length":"100","relationTable":null,"relationField":null,"validators":["str",["max","100"]]},"idProduct":{"name":"idProduct","type":"int","null":"NO","key":"","default":null,"extra":"","length":"11","relationTable":null,"relationField":null,"validators":["req","int",["max","11"]]},"_idProduct":{"name":"_idProduct","type":"varchar","null":"NO","key":"","default":null,"extra":"","length":"200","relationTable":null,"relationField":null,"validators":["req","str",["max","200"]]},"quantity":{"name":"quantity","type":"int","null":"NO","key":"","default":"0","extra":"","length":"11","relationTable":null,"relationField":null,"validators":["int",["max","11"]]},"idStatus":{"name":"idStatus","type":"int","null":"NO","key":"","default":null,"extra":"","length":"11","relationTable":null,"relationField":null,"validators":["req","int",["max","11"]]},"_idStatus":{"name":"_idStatus","type":"varchar","null":"NO","key":"","default":null,"extra":"","length":"100","relationTable":null,"relationField":null,"validators":["req","str",["max","100"]]}}},"attributeOrderDetail":{"data":[{"id":"1","idOrderDetail":"1","idOrder":"1","idAttribute":"1","_idAttribute":"usuario","value":"xopo","idType":"1"},{"id":"2","idOrderDetail":"1","idOrder":"1","idAttribute":"2","_idAttribute":"password","value":"CSDF4X2","idType":"1"},{"id":"3","idOrderDetail":"1","idOrder":"1","idAttribute":"3","_idAttribute":"fechaExpiracion","value":"2014-09-11","idType":"3"},{"id":"99","idOrderDetail":"1","idOrder":"1","idAttribute":"4","_idAttribute":"soporteRemoto","value":"1","idType":"4"}],"structure":{"id":{"name":"id","type":"int","null":"NO","key":"","default":"0","extra":"","length":"11","relationTable":null,"relationField":null,"validators":["int",["max","11"]]},"idOrderDetail":{"name":"idOrderDetail","type":"int","null":"NO","key":"","default":null,"extra":"","length":"11","relationTable":null,"relationField":null,"validators":["req","int",["max","11"]]},"idOrder":{"name":"idOrder","type":"int","null":"NO","key":"","default":null,"extra":"","length":"11","relationTable":null,"relationField":null,"validators":["req","int",["max","11"]]},"idAttribute":{"name":"idAttribute","type":"int","null":"NO","key":"","default":null,"extra":"","length":"11","relationTable":null,"relationField":null,"validators":["req","int",["max","11"]]},"_idAttribute":{"name":"_idAttribute","type":"varchar","null":"NO","key":"","default":"\"","extra":"","length":"100","relationTable":null,"relationField":null,"validators":["str",["max","100"]]},"value":{"name":"value","type":"varchar","null":"NO","key":"","default":null,"extra":"","length":"100","relationTable":null,"relationField":null,"validators":["req","str",["max","100"]]},"idType":{"name":"idType","type":"int","null":"NO","key":"","default":null,"extra":"","length":"1","relationTable":null,"relationField":null,"validators":["req","int",["max","1"]]}}}}; var orderDetail = result['orderDetail']; var attributeOrderDetail = result['attributeOrderDetail']; var theme = 'ui-redmond'; orderDetailData = orderDetail['data']?orderDetail['data']:[];//la primera vez lo cargo con los datos traidos de var sourceOrderDetail = { localdata: orderDetailData, //localdata:[], datatype: "array", async: false, root:"orderDetail", id:'id' }; var dataAdapterOrderDetail = new $.jqx.dataAdapter(sourceOrderDetail); var structureColumnsOrderDetail = formatStructure2(orderDetail['structure']); attributeOrderDetailData = attributeOrderDetail['data']?attributeOrderDetail['data']:[]; var initrowdetails = function (index, parentElement, gridElement, record) { var sourceAttributeOrderDetail = { localdata: attributeOrderDetailData, datatype: "array", async: false, root:"attributeOrderDetail" }; var dataAdapterAttributeOrderDetail = new $.jqx.dataAdapter(sourceAttributeOrderDetail, { autoBind: true }); var structureColumnsAttributeOrderDetail = formatStructure2(attributeOrderDetail['structure']); var recordsAttributesOrderDetail = dataAdapterAttributeOrderDetail.records; var id = record.id.toString(); var grid = $($(parentElement).children()[0]); nestedGrids.push(grid); var filtergroup = new $.jqx.filter(); var filtervalue = id; var filtercondition = 'equal'; var filter = filtergroup.createfilter('stringfilter', filtervalue, filtercondition); // fill the orders depending on the id. var ordersbyid = []; for (var m = 0; m < recordsAttributesOrderDetail.length; m++) { var result = filter.evaluate(recordsAttributesOrderDetail[m]["idOrderDetail"]); if (result) ordersbyid.push(recordsAttributesOrderDetail[m]); } var sourceAttributeOrderDetail = { id: 'id', localdata: ordersbyid }; if (grid != null) { grid.jqxGrid({ source: sourceAttributeOrderDetail, theme: theme, width: 600, height: 100, columns: structureColumnsAttributeOrderDetail }); } }; container.jqxGrid({ width: 670, height: 180, source: dataAdapterOrderDetail, theme: theme, rowdetails: true, rowsheight: 35, initrowdetails: initrowdetails, rowdetailstemplate: { initrowdetails: initrowdetails, rowdetails: "<div id='subGrid' style='margin: 10px;'></div>", rowdetailsheight: 220, rowdetailshidden: true }, ready: function () { }, columns: structureColumnsOrderDetail }); }//where result is an array as the used in the previous methodfunction refreshNestedGrid(result) { var container = $('#gridOrders); if (container.get(0) != 'undefined' && container.get(0) != null && container.get(0) != '' && container.get(0).tagName == 'DIV') { var sourceOrderDetail = container.jqxGrid('source'); if (sourceOrderDetail != null) { var orderDetail = result['orderDetail']; sourceOrderDetail.localData = orderDetail['data']?orderDetail['data']:[]; var dataAdapterOrderDetail = new $.jqx.dataAdapter(sourceOrderDetail); container.jqxGrid({source: dataAdapterOrderDetail}); container.jqxGrid('updatebounddata'); var attributeOrderDetail = result['attributeOrderDetail']; var initrowdetails = function (index, parentElement, gridElement, record) { var sourceAttributeOrderDetail = { localdata: attributeOrderDetail['data']?attributeOrderDetail['data']:[], //localdata: [], datatype: "array", async: false, id:"id", root:"attributeOrderDetail" }; var dataAdapterAttributeOrderDetail = new $.jqx.dataAdapter(sourceAttributeOrderDetail, { autoBind: true }); var structureColumnsAttributeOrderDetail = formatStructure2(attributeOrderDetail['structure']); var recordsAttributesOrderDetail = dataAdapterAttributeOrderDetail.records; var id = record.id.toString(); var grid = $($(parentElement).children()[0]); var filtergroup = new $.jqx.filter(); var filtervalue = id; var filtercondition = 'equal'; var filter = filtergroup.createfilter('stringfilter', filtervalue, filtercondition); // fill the orders depending on the id. var ordersbyid = []; for (var m = 0; m < recordsAttributesOrderDetail.length; m++) { var result = filter.evaluate(recordsAttributesOrderDetail[m]["idOrderDetail"]); if (result) ordersbyid.push(recordsAttributesOrderDetail[m]); } var sourceAttributeOrderDetail = { id: 'id', localdata: ordersbyid }; if (grid != null) { grid.jqxGrid({ source: sourceAttributeOrderDetail, theme: 'ui-redmond', width: 600, height: 100, columns: structureColumnsAttributeOrderDetail }); } }; container.jqxGrid({initrowdetails:initrowdetails}); } }}
I got the solution
First of all, I add the “main array” to the grid. Its means, that I add the array to the main row of the grid. Then, I force to show the details of that row, so that, the initrowdetails method is executed.
var arrayLineaPedido = {id:'temp1',idSellType:1,idProduct:3_idProduct:"super",quantity:3};$('#gridDetalle').jqxGrid('addrow', null, arrayLineaPedido); var rows = $('#gridDetalle').jqxGrid('getrows');$('#gridDetalle').jqxGrid('showrowdetails', rows.length-1);//tendria que ser el ultimo
So, in that way, I can add a row to the nestegrid as you said me
var linea = new Object();linea["id"]=null;linea['idOrderDetail']='temp1';linea['idAttribute']=1;linea['value']="un valor cualquiera";linea['idType']=1;nestedGrids[rows.length-1].jqxGrid('addrow', null, linea);
Thanks
Ok, but in my example the grid is empty, so the method initrowdetails has not been implemented yet.
The initrowdetails is executed when I desplegate one specific rowHow can I manage that?
Thanks in advance
August 23, 2013 at 12:26 pm in reply to: change the background-color cell when a cell changes its value change the background-color cell when a cell changes its value #27557Thansk..finally it’s working
You are the best
August 23, 2013 at 12:09 pm in reply to: change the background-color cell when a cell changes its value change the background-color cell when a cell changes its value #27554I have it
August 23, 2013 at 11:49 am in reply to: change the background-color cell when a cell changes its value change the background-color cell when a cell changes its value #27550I’m following the example, but it doesn’t work.
Here is my code
var container = $('#jqxgrid'); var data = [{available:true, id:'1',idEntity:'1',main:1,email:'bb@bb.es',idType:'1',_idType:'Personal'}]; var theme = 'ui-redmond'; var editedRows = new Array(); var source = { localdata: data, datatype: "array", async: false, deleterow: function (rowid, commit) { commit(true); }, addrow: function (rowid, rowdata, position, commit) { commit(true); }, updaterow: function (rowid, rowdata, commit) { // that function is called after each edit. var rowindex = container.jqxGrid('getrowboundindexbyid', rowid); editedRows.push({ index: rowindex, data: rowdata }); // synchronize with the server - send update command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failder. commit(true); } }; var dataAdapter = new $.jqx.dataAdapter(source); var cellclass = function (row, datafield, value, rowdata) { for (var i = 0; i < editedRows.length; i++) { if (editedRows[i].index == row) { return "editedRow"; } } }container.jqxGrid( { width: '100%', autoheight: true, source: dataAdapter, theme: 'ui-redmond', enablehover: false, selectionmode: 'multiplecellsadvanced', columnsresize: true, editable: true, columns: [ {text: '', datafield: 'available', columntype: 'checkbox', width: 40, renderer: function () { return '<div style="margin-left: 10px; margin-top: 5px;"></div>'; }}, { text: 'id', columntype: 'textbox', datafield: 'id', cellclassname: cellclass}, { text: 'idEntity', columntype: 'textbox', datafield: 'idEntity', cellclassname: cellclass}, { text: 'main', columntype: 'textbox', datafield: 'main', cellclassname: cellclass}, { text: 'email', columntype: 'textbox', datafield: 'email', cellclassname: cellclass}, { text: 'idType', columntype: 'textbox', datafield: 'idType', cellclassname: cellclass}, { text: '_idType', columntype: 'dropdownlist', datafield: '_idType',width:140, cellclassname: cellclass, createeditor: function(row, cellvalue, editor) { var source = new Array(); source[0] = {id:1, name:'personal', label: 'personal', value:'personal'}; source[1] = {id:1, name:'marketing', label: 'marketing', value:'marketing'}; var emailTypes = source; var mysource = { datatype: "array", datafields: [ { name: 'label', type: 'string' }, { name: 'value', type: 'string' } ], localdata: emailTypes }; var myadapter = new $.jqx.dataAdapter(mysource, { autoBind: true }); editor.jqxDropDownList({source: myadapter, displayMember: 'label', valueMember: 'value' }); } } ] });
In the css fle i have:
.editedRow { color: #b90f0f !important; font-style: italic;}
July 9, 2013 at 11:11 am in reply to: Not showing values when I put on the column Not showing values when I put on the column #24811I have the solution.
I have to delete the label: position:relation in every div, and Its works without problem.
<div id='jqxChartLine' style="width:680px; height:400px; position: relative; left: 0px; top: 0px;"></div>
July 9, 2013 at 10:41 am in reply to: Not showing values when I put on the column Not showing values when I put on the column #24808I have the problem when I have more than one jqxchart in the same file.
I show you the code that I have.
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.10.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxchart.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script><script type="text/javascript"> var settingsPie = { enableAnimations: true, showLegend: true, legendLayout: { left: 500, top: 140, width: 300, height: 200, flow: 'vertical' }, padding: { left: 5, top: 5, right: 5, bottom: 5 }, titlePadding: { left: 0, top: 0, right: 0, bottom: 10 }, // source: dataAdapter, colorScheme: 'scheme03', seriesGroups: [ { type: 'pie', showLabels: true, series: [ { dataField: 'valor', displayText: 'tipoOrden', labelRadius: 120, initialAngle: 15, radius: 95, centerOffset: 0, formatSettings: { sufix: '%', decimalPlaces: 1 } } ] } ] }; var settingsColumns = { showLegend: true, enableAnimations: true, padding: { left: 5, top: 5, right: 5, bottom: 5 }, titlePadding: { left: 90, top: 0, right: 0, bottom: 10 }, categoryAxis: { dataField: 'tipoGrafico', showGridLines: true }, colorScheme: 'scheme01', seriesGroups: [ { type: 'column', columnsGapPercent: 50, valueAxis: { unitInterval: 100, displayValueAxis: true, description: 'Euros' }, series: [ { dataField: 'euros_a_recuperar', displayText: 'Euros a recuperar'}, { dataField: 'euros_recuperados', displayText: 'Euros recuperados' }, { dataField: 'euros_perdidos', displayText: 'Euros perdidos' } ] } ] }; var settingsLine = { enableAnimations: true, showLegend: true, padding: { left: 10, top: 5, right: 10, bottom: 5 }, titlePadding: { left: 90, top: 0, right: 0, bottom: 10 }, //source: dataAdapter, categoryAxis: { dataField: 'fecha', formatFunction: function (value) { return (value.getMonth() + 1) + "-" + value.getFullYear(); }, toolTipFormatFunction: function (value) { return value.getDate() + '-' + (value.getMonth()+1)+ "-" + value.getFullYear(); }, type: 'date', baseUnit: 'month', showTickMarks: true, tickMarksInterval: 1, tickMarksColor: '#888888', unitInterval: 1, showGridLines: true, gridLinesInterval: 3, gridLinesColor: '#888888', valuesOnTicks: false }, colorScheme: 'scheme04', seriesGroups: [ { type: 'line', valueAxis: { unitInterval: 10, minValue: 0, maxValue: 100, displayValueAxis: true, description: 'Daily Closing Price', axisSize: 'auto', tickMarksColor: '#888888' }, series: [ { dataField: 'licencias_infractoras', displayText: 'Licencias Infractoras'}, { dataField: 'licencias_recuperadas', displayText: 'Licencias Recuperadas'}, { dataField: 'licencias_perdidas', displayText: 'Licencias Perdidas'} ] } ] };</script><table <tr> <td width="100%"> <script type="text/javascript"> $(document).ready(function () { //GRAFICO DE COLUMNAS PARA LOS PRECIOS RESPECTO DEL TOTAL DE ORDENES FRAUDULENTAS var source1 = [ { tipoGrafico: 'Total Fraudulentas', euros_a_recuperar: 100, euros_recuperados:60,euros_perdidos:30} ]; var dataAdapter1 = new $.jqx.dataAdapter(source1, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source1.url + '" : ' + error);} }); settingsColumns.title="Evolucion de los euros"; settingsColumns.description="Respecto del total de ordenes infractoras"; settingsColumns.source = dataAdapter1; $('#jqxChartGlobalColumnEuros').jqxChart(settingsColumns); //GRAFICO DE COLUMNAS PARA LOS PRECIOS RESPECTO DE LAS ORDENES FRAUDULENTAS TRATADAS var source2 = [ { tipoGrafico: 'Fraudulentas Tratadas', euros_a_recuperar: 80 , euros_recuperados:60,euros_perdidos:30} ]; var dataAdapter2 = new $.jqx.dataAdapter(source2, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source2.url + '" : ' + error);} }); settingsColumns.title="Evolucion de los euros"; settingsColumns.description="Respecto de las ordenes tratadas"; settingsColumns.source = dataAdapter2; $('#jqxChartParcialColumnEuros').jqxChart(settingsColumns); //GRAFICO DE LINEAS PARA EL HISTORICO var source= [ { fecha: '2013-01-01', licencias_infractoras: 80 , licencias_recuperadas:60,licencias_perdidas:30}, { fecha: '2013-02-01', licencias_infractoras: 50 , licencias_recuperadas:30,licencias_perdidas:20}, { fecha: '2013-03-01', licencias_infractoras: 100 , licencias_recuperadas:50,licencias_perdidas:10} ]; var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } }); settingsLine.title="Historico"; settingsLine.source = dataAdapter; $('#jqxChartLine').jqxChart(settingsLine); }); </script> <table width="95%" border="0" align="center" cellpadding="0"cellspacing="0"> <thead align="left"><tr><th colspan="5" style="padding-left: 10%" ></th></tr></thead> <tbody> <tr bgcolor="ffffff"> <td colspan="5"> <div id='jqxChartGlobalColumnEuros' style="width: 680px; height: 300px; position: relative; left: 0px;top: 0px;"></div> </td> <td colspan="5"> <div id='jqxChartParcialColumnEuros' style="width: 680px; height: 300px; position: relative; left: 0px;top: 0px;"></div> </td> </tr> <tr bgcolor="ffffff"> <td colspan="5"> <div id='jqxChartLine' style="width:680px; height:400px; position: relative; left: 0px; top: 0px;"></div> </td> </tr> </tbody> </table> </td> </tr> </table>
July 9, 2013 at 10:10 am in reply to: jqxchart line baseUnit month and year jqxchart line baseUnit month and year #24806Thanks a lot
It helps me a lot.
I try your example in an alone php and its works perfectly.
But if i put into the context of my aplication, doesn’t.In my aplication, I have a body with tabs:
<div id='mainLayout' style='height: 90%'> <div id='cabecera'style='height: 50px;'> <div style="float:left;"> <span class="tituloPrincipal">SGO</span> </div> </div> <div id='menu' style='visibility: hidden;'> <? include("views/tpl/Menu.php"); ?> </div> <div id='toolbar' style="height: 25px; padding: 5px;" class="jqx-widget-header"> abssdb </div> <div id='body' style="height:700px; width: 99.9%;"> <div id='tabs'> <ul><li></li></ul> <div></div> </div> </div> <div id='foot' style="height: 25px; padding: 5px;" class="jqx-widget-header"> foot </div></div>
Then, programatically, I delete the tab added, so visually, I don’t have tabs.
$(document).ready(function () { $("#cabecera").css({'background-image':'url(img/topMainBack.png)'}); $('#tabs').jqxTabs({ showCloseButtons: true ,selectionTracker: true ,theme: 'ui-redmond' , height:600}); $('#tabs').jqxTabs("removeFirst"); $('#menu').jqxMenu({ height: 30, theme: 'ui-redmond', width: '400px' }); $("#menu").css('visibility', 'visible');});
When someone click into the menu, then, I put their content into a iframe into the tab. The txt referenced the name of a php file.:
<li>Sección Principal <ul style='width: 250px;'> <li><a href='javascript:loadSubMenu("UsersLazy")' view="UsersLazy">UsersLazy</a></li> <li><a href='javascript:loadSubMenu("Orders")'view="Orders">Orders</a></li> <li><a href='javascript:loadSubMenu("Resellers")' view="Resellers">Distribuidores</a></li> <li><a href='javascript:loadSubMenu("Customers")' view="Customers">Clientes</a></li> </ul> </li>
//the variable contTab is to avoid repeat id for iframes.
function loadSubMenu(txt){ var data = "<iframe id='frame"+txt+"_"+contTab+ "' width='99.9%' height='99.9%' src = 'about:blank'></iframe>" $('#tabs').jqxTabs('addLast', txt, data); $('#tabs').jqxTabs('ensureVisible', -1); loadView(txt, "frame"+txt+"_"+contTab); contTab++; }
The function loadView, get the content of the php file and add put into the specific tab.
/**
* Function to load a specific view (viewName) into a div (container)
* If the parameter data is not null, show the view with the dates (modify).
*/function loadView(viewName, container,onSuccess, onError, async){ async= async!=null ? async: true; $.ajax({ type: "get", url: "loader.php", data:{v:viewName}, async:async }).done(function ( data ) { //puede cargar el contenido. Tiene Permisos if($("#" + container).prop("tagName")=="IFRAME"){ $('#'+container).contents().find("body").html(data); }else{ $('#'+container).html(data); $('script').each(function(){ var $this = $(this); if($this instanceof HTMLScriptElement){ require(["../views/js/" + viewName]); } }); } if (onSuccess!=null) onSuccess(); }).fail(function(jqXHR, textStatus){ if (onError!=null) onError(); }); }
The class Loader.php get the content of the php file.
Sorry, I don’t understand your answer.
I have a scroll on the bottom of the grid, but the problem is that I can’t select the scroll and move it trough the grid.
Ok. The problem is the horizontal scrolling, because I don’t put a width property on my columns, and I set de property autoresizecolumns to the grid, after being created.
Any solution?February 13, 2013 at 5:44 pm in reply to: Adjust width columns to the conten of cells Adjust width columns to the conten of cells #15196It just works.
I think that code wasn’t well situated into the code.
ThanksFebruary 8, 2013 at 8:19 am in reply to: Combo desplegated in other position Combo desplegated in other position #14883I think the problem is due the combo is inside the iframe…it’s like if the combo takes the coordenates inside the iframe, for example 200, 300, and desplegated the combo in that coordenates, but references to the general window, not inside the iframe…
Can you try to put a combo inside an iframe?
Thanks for your help
February 8, 2013 at 8:10 am in reply to: Combo desplegated in other position Combo desplegated in other position #14880Data are properly desplegated, but the problem is that data aren’t desplegated below the combo, data are desplegated very far away.
I must say that the combo is inside an iframe.
I can’t attach an image with the capture of the window :(. The combo is in the middle of the window, and the desplegation is in the left of the window, in a point where nothing is in that place.
-
AuthorPosts