jQWidgets Forums
Forum Replies Created
-
Author
-
Hi,
I have managed to solve this issue. I was able to find something in another post which led me to the answer, and when I looked at the examples again it became even clearer.
So the solution was to change initlevel3 as follows
var initlevel3 = function (index, parentElement, gridElement, datarecord) {
//Comment for solution – Added the extra parameters which allowed me to get the id much easier
var grid = $($.find(‘#rabbreedgrid’ + index));
var row = index;
var id = $(gridElement).jqxGrid(‘getrowdata’,row)[‘id’];
// changed this to use the gridElement but I also was using the wrong field needed id from parent
grid.bind(‘bindingcomplete’, function (event) {
if (event.target.id == “breedgrid” + index) {
grid.jqxGrid(‘beginupdate’);
var datainformation = grid.jqxGrid(‘getdatainformation’);
for (var i = 0; i < datainformation.rowscount; i++) {
var hidden = true;
grid.jqxGrid('setrowdetails', i, "“, 220, hidden);
}
grid.jqxGrid(‘endupdate’);
}
});
if (grid != null) {
//rabbit colour
var rabcoloururl = “../rabbitcolour/rcJsonlist”;
// prepare the data
var rabcolourjson =
{
datatype: “json”,
data: {rabbitbreedid: id},
datafields: [
{ name: ‘id’},
{ name: ‘RabbitColourName’},
{ name: ‘RabbitColourOrder’},
{ name: ‘RabbitBreedId’}
],
//root: “rbJsonlist”,
//id: ‘id’,
async:false,
url: rabcoloururl
};var rcdataAdapter = new $.jqx.dataAdapter(rabcolourjson, { autoBind: true });
grid.jqxGrid({
source: rcdataAdapter,
theme: theme,
width: 530,
height: 200,
columns: [
{ text: ‘id’, dataField: ‘id’, width: 100 },
{ text: ‘Colour’, dataField: ‘RabbitColourName’, width: 100 },
{ text: ‘Order’, dataField: ‘RabbitColourOrder’, width: 80 },
{ text: ‘Breed Id’, dataField: ‘RabbitBreedId’ }
]
});
}
}So thank you for your help not only on this post but in other posts as well.
Regards,
Neil
Thanks,
I have managed to get data displaying but I just can’t seem to get the restriction on the 3rd tier.
My code is as follows:
$(document).ready(function () {
var theme = ‘darkblue’;//getDemoTheme();// prepare the data
var data = new Array();
var firstNames =
[
“Andrew”, “Nancy”, “Shelley”, “Regina”, “Yoshi”, “Antoni”, “Mayumi”, “Ian”, “Peter”, “Lars”, “Petra”, “Martin”, “Sven”, “Elio”, “Beate”, “Cheryl”, “Michael”, “Guylene”
];
var lastNames =
[
“Fuller”, “Davolio”, “Burke”, “Murphy”, “Nagase”, “Saavedra”, “Ohno”, “Devling”, “Wilson”, “Peterson”, “Winkler”, “Bein”, “Petersen”, “Rossi”, “Vileid”, “Saylor”, “Bjorn”, “Nodier”
];
var productNames =
[
“Black Tea”, “Green Tea”, “Caffe Espresso”, “Doubleshot Espresso”, “Caffe Latte”, “White Chocolate Mocha”, “Cramel Latte”, “Caffe Americano”, “Cappuccino”, “Espresso Truffle”, “Espresso con Panna”, “Peppermint Mocha Twist”
];
var priceValues =
[
“2.25”, “1.5”, “3.0”, “3.3”, “4.5”, “3.6”, “3.8”, “2.5”, “5.0”, “1.75”, “3.25”, “4.0”
];
for (var i = 0; i < 10; i++) {
var row = {};
var productindex = Math.floor(Math.random() * productNames.length);
var price = parseFloat(priceValues[productindex]);
var quantity = 1 + Math.round(Math.random() * 10);
row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)];
row["productname"] = productNames[productindex];
row["price"] = price;
row["quantity"] = quantity;
row["total"] = price * quantity;
data[i] = row;
}
var source =
{
localdata: data,
datatype: "array"
};var rabsectionurl = "Jsonlist";
// prepare the data
var rabsection =
{
datatype: "json",
datafields: [
{ name: 'RabbitSectionId'},
{ name: 'RabbitSectionName'},
{ name: 'RabbitSectionOrder' },
],
root: "Jsonlist",
async:false,
id: 'RabbitSectionId',
url: rabsectionurl
};var rsdataAdapter = new $.jqx.dataAdapter(rabsection);
// set rows details.
$("#jqxgrid").bind('bindingcomplete', function (event) {
if (event.target.id == "jqxgrid") {
$("#jqxgrid").jqxGrid('beginupdate');
var datainformation = $("#jqxgrid").jqxGrid('getdatainformation');
for (i = 0; i 0 ? true : false;
$(“#jqxgrid”).jqxGrid(‘setrowdetails’, i, ““, 220, hidden);
}
$(“#jqxgrid”).jqxGrid(‘endupdate’);
}
});var initlevel3 = function (index) {
var grid = $($.find(‘#subgrid’ + index));
var row = index;
var id = $(“#grid.jqxgrid”).jqxGrid(‘getrowdata’,row)[‘RabbitBreedId’];
//var id = $(“#jqxgrid”).jqxGrid(‘getrowdata’, row)[‘RabbitBreedId’];
//var dataAdapter = new $.jqx.dataAdapter(source);
if (grid != null) {
//rabbit colour
var rabcoloururl = “../rabbitcolour/rcJsonlist”;
// prepare the data
var rabcolourjson =
{
datatype: “json”,
data: {rabbitbreedid: id},
datafields: [
{ name: ‘id’},
{ name: ‘RabbitColourName’},
{ name: ‘RabbitColourOrder’},
{ name: ‘RabbitBreedId’}
],
//root: “rbJsonlist”,
//id: ‘id’,
async:false,
url: rabcoloururl
};var rcdataAdapter = new $.jqx.dataAdapter(rabcolourjson, { autoBind: true });
grid.jqxGrid({
source: rcdataAdapter,
theme: theme,
width: 530,
height: 200,
columns: [
{ text: ‘id’, dataField: ‘id’, width: 100 },
{ text: ‘Colour’, dataField: ‘RabbitColourName’, width: 100 },
{ text: ‘Order’, dataField: ‘RabbitColourOrder’, width: 80 },
{ text: ‘Breed Id’, dataField: ‘RabbitBreedId’ }
]
});
}
}//var dataAdapter = new $.jqx.dataAdapter(source);
// create nested grid.
var initlevel2 = function (index) {
var grid = $($.find(‘#grid’ + index));
var row = index;
var id = $(“#jqxgrid”).jqxGrid(‘getrowdata’, row)[‘RabbitSectionId’];
grid.bind(‘bindingcomplete’, function (event) {
if (event.target.id == “grid” + index) {
grid.jqxGrid(‘beginupdate’);
var datainformation = grid.jqxGrid(‘getdatainformation’);
for (var i = 0; i < datainformation.rowscount; i++) {
var hidden = true;
grid.jqxGrid('setrowdetails', i, "“, 220, hidden);
}
grid.jqxGrid(‘endupdate’);
}
});if (grid != null) {
//var dataAdapter = new $.jqx.dataAdapter(source);
//rabbit breed
var rabbreedurl = “../rabbitbreed/rbJsonlist”;
// prepare the data
var rabbreedjson =
{
datatype: “json”,
data: {rabbitsectionid: id, gridrow: row},
datafields: [
{ name: ‘id’},
{ name: ‘RabbitBreedName’},
{ name: ‘RabbitBreedOrder’},
{ name: ‘RabbitSectionId’}
],
//root: “rbJsonlist”,
//id: ‘id’,
async:false,
url: rabbreedurl
};var rbdataAdapter = new $.jqx.dataAdapter(rabbreedjson, { autoBind: true });
grid.jqxGrid({
rowdetails: true,
initrowdetails: initlevel3,
source: rbdataAdapter,
theme: theme,
width: 600,
height: 200,
columns: [
{ text: ‘id’, datafield: ‘id’, width: 30 },
{ text: ‘Breed’, datafield: ‘RabbitBreedName’, width: 600 },
{ text: ‘Order’, datafield: ‘RabbitBreedOrder’, width: 50 },
{ text: ‘Section’, datafield: ‘RabbitSectionId’, width: 50 }
]
});
}
}// creage jqxgrid
$(“#jqxgrid”).jqxGrid(
{
width: 670,
height: 365,
source: rsdataAdapter,
theme: theme,
rowdetails: true,
initrowdetails: initlevel2,
columns: [
{ text: ‘id’, datafield: ‘RabbitSectionId’, width: 30 },
{ text: ‘Name’, datafield: ‘RabbitSectionName’, width: 600 },
{ text: ‘Order’, datafield: ‘RabbitSectionOrder’, width: 50 },
]
});});
This is the code which I believe this is the problem but I don’t know how to change this to get the value back from the 2nd tier nested grid. (It is in initlevel3)
var id = $(“#jqxgrid”).jqxGrid(‘getrowdata’,row)[‘RabbitBreedId’];
If I force id to a value I can restrict it correctly. I just need to know how to know which row has been expanded so help would be appreciated.
Regards,
Neil
-
AuthorPosts