I've got a script that generates a form panel:
var form = new Ext.FormPanel({
id: 'form-exploit-zombie-' + zombie_ip,
formId: 'form-exploit-zombie-' + zombie_ip,
border: false,
labelWidth: 75,
formBind: true,
defaultType: 'textfield',
url: '/ui/modules/exploit/new',
autoHeight: true,
buttons: [{
text: 'Execute exploit',
handler: function () {
var form = Ext.getCmp('form-exploit-zombie-' + zombie_ip);
form.getForm().submit({
waitMsg: 'Running exploit ...',
success: function () {
Ext.beef.msg('Yeh!', 'Exploit sent to the zombie.')
},
failure: function () {
Ext.beef.msg('Ehhh!', 'An error occured while trying to send the exploit.')
}
});
}
}]
});
that same scripts then retrieves a json file from my server which defines how many input fields that form should contain. The script then adds those fields to the form:
Ext.each(inputs, function(input) {
var input_name;
var input_type = 'TextField';
var input_definition = new Array();
if(typeof input == 'string') {
input_name = input;
var field = new Ext.form.TextField({
id: 'form-zombie-'+zombie_ip+'-field-'+input_name,
fieldLabel: input_name,
name: 'txt_'+input_name,
width: 175,
allowBlank:false
});
form.add(field);
}
else if(typeof input == 'object') {
//input_name = array_key(input);
for(definition in input) {
if(typeof definition == 'string') {
}
}
} else {
return;
}
});
Finally, the form is added to the appropriate panel in my interface:
panel.add(form);
panel.doLayout();
The problem I have is: when I submit the form by clicking on the button, the http request sent to my server does not contain the fields added to the form. In other words, I'm not posting those fields to the server.
Anyone knows why and how I could fix that?
Your problem is here:
id: 'form-exploit-zombie-'+zombie_ip,
formId: 'form-exploit-zombie-'+zombie_ip,
what you are doing is that you are setting the id attribute of the form panel and the id attribute of the form (form tag) to the same value. Which means that you have two elements with the same id and that is wrong.
Just remove this line
formId: 'form-exploit-zombie-'+zombie_ip,
and you should be fine.
Did you check the HTTP Request parameter for the form values?
If you server side is in PHP, what do you get from response by passing any field name? For example, if one of your input name was "xyz" what do you get by
$_POST[ 'txt_xyz' ]
Related
I have dropdown, checkboxes and button submit. First, the user will choose at dropdown (position of work). Second, the user will select the checkbox and after that submit the data. Here, after refresh it should be appear back the previous selected dropdown and checkbox. But, I did not get it. Anyone here have more better solution?
JavaScript Dropdown
//dropdown position
$("#dropdown").kendoDropDownList({
optionLabel: "- Select Position -",
dataTextField: "functionName",
dataValueField: "hrsPositionID",
dataSource: {
transport:{
read: {
url: "../DesignationProgramTemplate/getData.php",
type: "POST",
data: function() {
return {
method: "getDropdown",
}
}
},
},
},
change: onChange
}).data('kendoDropDownList');
dropdownlist = $("#dropdown").data("kendoDropDownList");
Checkbox treeview (Kendo UI)
homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: serviceRoot,
dataType: "json"
}
},
schema: {
model: {
id : "ehorsProgramID",
hasChildren: false,
children : "items"
}
},
filter: { field: "module", operator: "startswith", value: "Accounting" }
});
$("#AccountingTree").kendoTreeView({
check: onCheck,
checkboxes: { checkChildren: true } ,
// select: onSelect,
dataSource: homogeneous,
dataBound: function(){
this.expand('.k-item');
},
dataTextField: ["module","groupname","ehorsProgramName"]
});
AJAX for submit button
//AJAX call for button
$("#primaryTextButton").kendoButton();
var button = $("#primaryTextButton").data("kendoButton");
button.bind("click", function(e) {
var test = $("#dropdown").val()
$.ajax({
url: "../DesignationProgramTemplate/getTemplate.php",
type: "post",
data: {'id':test,'progid':array},
success: function () {
// you will get response from your php page (what you echo or print)
kendo.alert('Success'); // alert notification
//refresh
//location.reload("http://hq-global.winx.ehors.com:9280/ehors/HumanResource/EmployeeManagement/DesignationProgramTemplate/template.php");
},
});
});
JavaScript for check checkboxes
function checkedNodeIds(nodes, checkedNodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].checked) {
checkedNodes.push(nodes[i].id);
}
if (nodes[i].hasChildren) {
checkedNodeIds(nodes[i].children.view(), checkedNodes);
}
}
}
var array = [];
function onCheck() {
var checkedNodes = [],treeView = $("#AccountingTree").data("kendoTreeView"),message;
var checkedNodes2 = [],treeView2 = $("#AdminSystemTree").data("kendoTreeView"),message;
var checkedNodes3 = [],treeView3 = $("#FnBTree").data("kendoTreeView"),message;
var checkedNodes4 = [],treeView4 = $("#HumanResourceTree").data("kendoTreeView"),message;
var checkedNodes5 = [],treeView5 = $("#InventoryManagementTree").data("kendoTreeView"),message;
var checkedNodes6 = [],treeView6 = $("#SalesMarketingTree").data("kendoTreeView"),message;
checkedNodeIds(treeView.dataSource.view(), checkedNodes);
checkedNodeIds(treeView2.dataSource.view(), checkedNodes);
checkedNodeIds(treeView3.dataSource.view(), checkedNodes);
checkedNodeIds(treeView4.dataSource.view(), checkedNodes);
checkedNodeIds(treeView5.dataSource.view(), checkedNodes);
checkedNodeIds(treeView6.dataSource.view(), checkedNodes);
if (checkedNodes.length > 0) {
message = checkedNodes.filter(x => !!x).join(",");
array = checkedNodes.filter(x => !!x);
} else {
message = "No nodes checked.";
}
}
Output
JavaScript for accessing the dataItem
// cookies
var values = ["LA1","LA6","LA12"]; //array nnti array ni la localstorage/cookies
var setTreeViewValues = function(values) {
var tv = $("#AccountingTree").data("kendoTreeView");
document.write(JSON.stringify(tv));
tv.forEach(function(dataItem) {
alert("test");
if (dataItem.hasChildren) {
var childItems = dataItem.children.data();
//document.write(JSON.stringify(childItems[0].items[0].programID));
}
// document.write(JSON.stringify(dataItem.items));
if (values.indexOf(childItems[0].items[0].programID) > -1) {
dataItem.set("checked", true);
}
});
};
setTreeViewValues(values);
console.log(datasource.data()[0].hasChildren);
// end cookies
So without knowing how you are binding the existing values to the page I am assuming you will be calling the page state somewhere within your Page loading.
So I have prepared a dojo that shows two different ways of setting the checked state of the items.
https://dojo.telerik.com/EhaMIDAt/8
1. Setting at the DataSource Level
So when setting up the datasource you can add an extra attribute to your collection called checked this will then set the checked value for the item or children items when loaded. using the example I have in the dojo:
{
id: 9,
text: "Reports",
expanded: true,
spriteCssClass: "folder",
items: [{
id: 10,
text: "February.pdf",
spriteCssClass: "pdf"
},
{
id: 11,
text: "March.pdf",
spriteCssClass: "pdf",
checked: true
},
{
id: 12,
text: "April.pdf",
spriteCssClass: "pdf"
}
]
}
this will set the checked state to true for you and show the checkbox as checked.
2. Manually Set the values after loading all the DataSources.
So I have done this on a button click but this could easily be done on a ready state or some other trigger if needed. Here the button when clicked will find the node in the tree with the text Research.pdf and either set it in a checked or unchecked state for you.
$('#checked').bind('click', () => {
var box = $("#treeview").data("kendoTreeView").findByText('Research.pdf').find('input[type="checkbox"]');
box.prop('checked', !box.is(':checked'));
});
Again the sample it taken from dojo link above. Hopefully this gives you a start on getting the values set according to your specific requirements.
I would probably have the value checked state set when you load the datasource for the treeview.
I have created a form in netsuite such that after it has been posted it should redirect to the the selected record. It's not occuring - what am I doing wrong?
if (request.getMethod() == 'GET') {
var slcustomer = form.addField('custpage_selectfield', 'select',
'Customer', 'customer');
form.addSubmitButton('Submit'); //For submiting as i will check for post back
response.writePage(form); //Write the form or display the form
} else {
if (request.getMethod() == 'POST') {
var task = request.getParameter('slcustomer');
nlapiSetRedirectURL('RECORD', 'task', null, false);
}
}
I tried using your code inside a suitelet function and it worked for me.
function suitelet(request, response){
if (request.getMethod() == 'GET') {
var form = nlapiCreateForm('My Custom Form', false);
var slcustomer = form.addField('custpage_selectfield', 'select',
'Customer', 'customer');
form.addSubmitButton('Submit'); //For submiting as i will check for post back
response.writePage(form); //Write the form or display the form
} else {
if (request.getMethod() == 'POST') {
var customerid = request.getParameter('custpage_selectfield');
nlapiLogExecution('debug', 'selected id', customerid);
nlapiSetRedirectURL('RECORD', 'task', null, false);
}
}
}
var slcustomer = form.addField('custpage_selectfield', 'select',
'Customer', 'customer');
This line creates a drop down list of Customer records.
var task = request.getParameter('custpage_selectfield');
nlapiLogExecution('debug', 'selected id', task);
nlapiSetRedirectURL('RECORD', 'task', null, false);
The task variable should contain the internal id of the selected customer. Your nlapiSetRedirectURL call is incorrect. If you want to redirect to the selected customer, it should be
nlapiSetRedirectURL('RECORD', 'customer', task);
I have a extjs form with has names like
udField[1]
udFIeld[2]
I can save it on server side without problems. But when i want to laod the form it just wont populate the value....
Here is on example from the ud dield:
{
labelSeparator: config.required == 1 ? ': <span style="color:red">*</span>' : ':',
allowBlank: config.required == 0,
emptyText: config.options.blankText,
xtype: 'textfield',
name: 'udFields[' + config.options.udFieldId + ']',
flex: 0,
fieldLabel: Ext.lang(config.display_name),
}
And here is how i load it:
Ext.getCmp('rootform').getForm().load({
url: 'ajax/Freetext/Article/LoadSingle',
waitMsg: Ext.lang('t_warenkorb_wird_geladen'),
params: {
cartarticle_id: cartarticleId,
sid: config.sid
},
success: function (form) {
some checks and other stuff
}
I get the correct response from the server to this is the response json data:
amount: "1"
cartarticle_id: "xxx"
catalogpartner_id_freetxt: "xxx"
delivery_date: "15.04.2015"
description_long: "test "
description_short: "test"
manufacturer_aid: "xxx"
manufacturer_name: "xxxxxx"
order_unit: "PAK"
price_amount: "122.12"
remarks: "test"
supplier_aid: "test"
udFields[123]: "test"
but the damn thing wont load no mather what.... anyone has some ideas???
ps here is the whole json string with obscured data:
{"success":true,"data":{"catalogpartner_id_freetxt":"12","description_short":"test","cartarticle_id":"12","amount":"1","order_unit":"PAK","price_amount":"122.12","delivery_date":"15.04.2015","description_long":"test ","remarks":"test","supplier_aid":"test","manufacturer_name":"Datenbank feiger Text (#todo)","manufacturer_aid":"Datenbank feiger Text (#todo)","udFields[123]":"test"},"debug":["11.05.2015 16:58:20.860232 params:Array\n(\n [cartarticle_id] => 312\n [sid] => 132\n)\n<br><BR>"]}
Well i could not figure out how to configure it. tried varios ways. In end i made a post sucess parser from an array....
Not pretty but only solution i could rely on....
success: function (form, data) {
if (data.result.data)
if (data.result.data.udFields) {
for (var key in data.result.data.udFields) {
var element = data.result.data.udFields[key];
var input = form.findField('udFields' + element.id);
if (input)
input.setValue(element.value);
}
}...
Hi I'm very new to 'Ext JS' (about 4 days) and have to edit 'Ext JS' form. That form is to edit existing entry. So I have to update 'project name' field in this form and need to follow following conditions.
Users can submit form with its old project name (old old project
name means project name when form is load).
When user select existing project name from suggestion drop down (except old project name), need to show error.
Basic idea of this conditions is prevent duplicate project names.
So I try to do this with 'validator' but I can't find a way to compare old project name and new project name.
Is there any method to compare those values ??
Any other way to validate this field ???
this is what I have done so far...
_est.project.view.panel.updateprojectname.combox = function (projectdetails) {
var nstore = _est.project.view.panel.updateprojectnstore();
var combo = Ext.create('Ext.form.ComboBox', {
fieldLabel: _est.project.text.nameText,
store: nstore,
labelSeparator: ' ',
vtype: 'text',
afterLabelTextTpl: _est.afterLabelTextRequiredTpl,
msgTarget: 'side',
displayField: 'projectname',
valueField: 'projectname',
labelWidth: 130,
maxLength: 200
name: 'projectname',
allowBlank: false,
pageSize: true,
triggerAction: 'query',
autoSelect: true,
minChars: 0,
itemId : 'project-name-field',
value: Ext.htmlDecode(projectdetails.projectname),
hideTrigger: true,
anchor: '95%',
validator: function(oldValue) {
var existnstore = Ext.StoreMgr.lookup("ptoject-project-names-get-store");
if(existnstore){
var nstore = existnstore.findExact('projectname',oldValue);
if(nstore < 0){
return true;
}else{
return 'Job name already exist.';
}
}
},
listConfig: {
getInnerTpl: function () {
return '<a class="search-item">' +
'<span>{projectstate}</span>' +
'{projectname}' +
'</a>';
}
},
});
return combo;
}
any suggestions or opinions to do this :) thanks in advance..
I change 'validator' function and this work for me
validator: function(Value) {
var existname = projectdetails.projectname;
if(Value !== existname){
var existnamestore = Ext.StoreMgr.lookup("update-ptoject-project-names-get");
if(existnamestore){
var namestore = existnamestore.findExact('projectname',Value);
if(namestore < 0){
return true;
}else{
return 'Job name already exist. Please select different job name.';
}
}
}
return true;
}
As the title said it, how do I do it?, I am using this button created by jiri:
How do i create a delete button on every row using the SlickGrid plugin?
when I add an if(confirmation(msg)) inside the function it repeats me the msg ALOT
maybe its because i refresh-ajax the table with each modification.
ask me if you need more info, I am still noob here in stackoverflow :P
(also if there is someway to "kill" the function)
here is the button, iam using(link) i added the idBorrada to check whetever the id was already deleted and dont try to delete it twice, also here is a confirm, but when i touch cancel it asks me again.
$('.del').live('click', function(){
var me = $(this), id = me.attr('id');
//assuming you have used a dataView to create your grid
//also assuming that its variable name is called 'dataView'
//use the following code to get the item to be deleted from it
if(idBorrada != id && confirm("¿Seguro desea eleminarlo?")){
dataView.deleteItem(id);
Wicket.Ajax.ajax({"u":"${url}","c":"${gridId}","ep":{'borrar':JSON.stringify(id, null, 2)}});
//This is possible because in the formatter we have assigned the row id itself as the button id;
//now assuming your grid is called 'grid'
//TODO
grid.invalidate();
idBorrada= id;
}
else{
};
});
and i call the entire function again.
hope that help, sorry for the grammar its not my native language
Follow these steps,
Add a delete link for each row with of the columns object as follows,
var columns =
{ id: "Type", name: "Application Type", field: "ApplicationType", width: 100, cssClass: "cell-title", editor: Slick.Editors.Text, validator: requiredFieldValidator, sortable: true },
{ id: "delete", name: "Action", width: 40, cssClass: "cell-title", formatter: Slick.Formatters.Link }
];
Add a Link Formatter inside slick.formatters.js as follows,
"Formatters": {
"PercentComplete": PercentCompleteFormatter,
"YesNo": YesNoFormatter,
"Link": LinkFormatter
}
function LinkFormatter(row, cell, value, columnDef, dataContext) {
return "<a style='color:#4996D0; text-decoration:none;cursor:pointer' onclick='DeleteData(" + dataContext.Id + ", " + row + ")'>Delete</a>";
}
Add the following delete function in javascript
function DeleteData(id, rowId) {
var result = confirm("Are you sure you want to permenantly delete this record!");
if (result == true) {
if (id) {
$.ajax({
type: "POST",
url: "DeleteURL",
data: { id: id },
dataType: "text",
success: function () {
},
error: function () {
}
});
}
dataView.deleteItem(id);
dataView.refresh();}
}