Reputation: 190
I have a jsp page material.jsp with following code snippet :
<script type="text/javascript">
$(document).ready(function() {
$('#MaterialTableContainer').jtable({
title : 'Table of Materials',
actions : {
listAction : 'CRUDControllerForMaterial?action=list',
createAction : 'CRUDControllerForMaterial?action=create',
updateAction : 'CRUDControllerForMaterial?action=update',
deleteAction : 'CRUDControllerForMaterial?action=delete' },
fields : {
id : {
title : 'ID',
key : true,
list : true,
create : true
},
materialName : {
title : 'MaterialName',
width : '30%',
edit : true
},
description : {
title : 'Description',
width : '30%',
edit : true
},
lastModifiedComments : {
title : 'LastModifiedComments',
width : '20%',
edit : true
},
materialClassID : {
title : 'MaterialClassID',
width : '50%',
edit : true,
options : ["1","2","3","4","5"]
},
isMaster : {
title : 'IsMaster',
width : '50%',
edit : true
}
}});
$('#MaterialTableContainer').jtable('load');
});
</script>
Now, in this, I want materialClassID to be a dropdown. So, in options, I have hard-coded values as ["1","2","3","4","5"].
But, these values are to be dynamic, i.e., these values should be fetched from the server (servlet) at runtime. So, how can I make a call to a function at this point, and retrieve the list/result-set.
We are using servlet-jsp, so I would need to write the code in Java.
Any suggestion would be of great help.
Thanks in advance.
Upvotes: 0
Views: 2301
Reputation: 1044
This worked for me call the php to return the needed data.
materialClassID : {
title : 'MaterialClassID',
width : '50%',
edit : true,
options : 'http://sample.com/sample.php?get=numbers'
}
Upvotes: 1
Reputation: 201537
Try something like this (assuming you've fetched your jsonMatArray already) -
materialClassID : {
title : 'MaterialClassID',
width : '50%',
edit : true
}
materialClassID.prototype.options = jsonMatArray;
or (the more usual) -
materialClassID : {
title : 'MaterialClassID',
width : '50%',
edit : true,
options : jsonMatArray
}
Upvotes: 0