kendo grid foreign key on Addition - foreign-keys

I am able to use Foreign Key column in a Kendo Grid. Using inline editing method, the "edit" action is working fine.
However, when adding a new record, every thing is fine on display. The foreign key column allows me to select value. But clicking the update button, the foreign key column value is null and subsequently unable to update database in my case.
Any advise how to resolve this.

I had same problem, Kendo UI isn't resolved problem yet (15/08/2014).
I resolved adding a client event on grid:
#(Html.Kendo().Grid<SPDProject.Models.DTO.ProyectoDTO>()
.Name("GridProyectos")
.Columns(columns =>
{
columns.Bound(r => r.Id).Visible(false);
columns.Bound(r => r.Nombre).Width(150);
columns.Bound(r => r.Alias).Width(150);
columns.ForeignKey(r => r.IdCliente, (System.Collections.IEnumerable)ViewData["IdCliente_Data"], "Value", "Text");
columns.ForeignKey(r => r.IdTipoProyecto, (System.Collections.IEnumerable)ViewData["IdTipoProyecto_Data"], "Value", "Text");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Events(events => events.Error("error_handler"))
.Create(create => create.Action("CreateProyecto", "Admin"))
.Destroy(destroy => destroy.Action("DestroyProyecto", "Admin"))
.Model(model => model.Id(r => r.Id))
.Read(read => read.Action("ReadProyecto", "Admin"))
.Update(update => update.Action("UpdateProyecto", "Admin")))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable(pageable => pageable.Refresh(true))
.Reorderable(reorderable => reorderable.Columns(true))
.Events(events => events.Save("onSave"))
.Resizable(resizable => resizable.Columns(true))
.Scrollable(scrollable => scrollable.Height(250))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
.Sortable(sortable => sortable.AllowUnsort(true).SortMode(GridSortMode.MultipleColumn))
.ToolBar(toolBar => toolBar.Create()))
<script type="text/javascript">
function onSave(e) {
//set the value to the model
e.model.set('IdCliente', $('#IdCliente').val());
e.model.set('IdTipoProyecto', $('#IdTipoProyecto').val());
}
I hope this helps somebody.
Regards,
Mauro at DreamSys

Related

How to get a full_html textarea field in a Drupal 8 configuration form?

In my module I have a configuration form (ConfigFormBase) with a simple textarea field without formatting that works correctly.
$form['page_message'] = [
'#type' => 'textarea',
'#title' => $this->t('Message'),
'#description' => $this->t('Message display to customer contacts.'),
'#default_value' => $config->get('page_message'),
];
But I would like a textarea full_html field.
Is this possible and how with Drupal 8?
Yes it is possible, but you have to do it like this:
$form['page_message'] = [
'#type' => 'text_format',
'#title' => $this->t('Message'),
'#format' => 'full_html',
'#description' => $this->t('Message display to customer contacts.'),
'#default_value' => $config->get('page_message'),
];
You can check Drupal api for TextFormat.php here, just click on view source and you will have all the info you need.

Creating Salesorder with Vtiger Webservice missing Tax

I have the Problem when creating an salesorder with Vtiger Webservice,
The sales order is created but somehow the tax is not added.
I thought it has something to do with the parameter : hdnTaxType
Cause even if I add this value 'group' it does not apply the Tax to the Salesorder.
I have to manually add The Taxtype 'group' then the system adds the tax.
thats why i tried to add values like:
'tax1' => '7.00',
and
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
nothing so far did help...
has anybody an Idea what the problem is?
Thank you
Tobi
$salesOrder =[
'lastname' => $customer['lastname'],
'subject' => 'Order from 01.01.1018',
'sostatus' => '1',
'assigned_user_id' => '',
'bill_street' => 'Rechunngsstrasse 123',
'ship_street' =>'Lieferungsstrasse 123',
'productid' => '14x4325',
'currency_id' => '21x1',
'carrier' => 'DHL',
'txtAdjustment' => '13',
'salescommission' => '12',
'exciseduty' => '15',
'hdnTaxType' => 'group',
'tax1' => '7.00',
'hdnS_H_Amount' => '22.22',
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
'LineItems' => [
0 => [
"taxid" => "33x1",
'productid'=>'14x6',
'listprice'=>'20.53',
'quantity'=>'3',
'comment' => "Product123"
]
]
Webservices in Vtiger are not complete.
In this case you can register your own webservice that makes your queries, or check the SalesOrder in the after-save event

Filtering is not working for child grid in kendo-ui hierarchical grid with Razor MVC

I am trying to implement filtering on child grid in kendo-ui hierarchical grid in MVC but it's giving error.
HTML Code Sample :
.Columns(col =>
{
col.Bound(o => o.Id).Hidden(true);
col.Bound(o => o.Column1).Width(100).ClientTemplate("\\#= BuildLink(data,'1') \\#");
col.Bound(o => o.Column2).Width(100).ClientTemplate("\\#= BuildLink(data,'2') \\#");
col.Bound(o => o.Column3).Width(100).ClientTemplate("\\#= BuildLink(data,'3') \\#");
col.Bound(o => o.YTDSailedCalls).Width(100).ClientTemplate("\\#= BuildLink(data,'4') \\#");
})
.Sortable().Scrollable().Filterable()
.Pageable(pageable => pageable.Refresh(true)
.PageSizes(new int[5] { 20, 40, 80, 100, 200 })
.ButtonCount(5))
but its giving error in browser console and nothing get displayed.
Please reply as soon as possible if anyone face this issue or have solution for this.
Try like this-
#(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(225);
columns.Bound(p => p.ShipName).Width(500).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.Freight).Width(255).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}");
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(true)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)
For more assistance refer this link-
Kendo Grid filter

Doctrine Module objectSelect setvalue not working

I have a simple question regarding Doctrine Modules Object Select.
I have a simple objectSelect form element
$this->add(array(
'name' => 'timezone',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'label' => _('Timezone:'),
'label_attributes' => array('class' => 'required'),
'object_manager' => $this->getEntityManager(),
'target_class' => 'Application\Entity\Timezones',
'property' => 'timezone',
'is_method' => true,
'find_method' => array(
'name' => 'FindAll',
),
),
));
Now I want to select a certain option as default, I have used the setValue method to do this but it is not working.
$this->get('timezone')->setValue(335);
Does anyone know why this is?
Many thanks in advance.
I figured out why it wasn't working.
In my controller I was binding my form to a Doctrine entity which was empty. This was overriding my values I set. I added the values in my controller after the form was bound and this fixed the issue.
$entityManager = $this->getEntityManager();
$site = new Sites($this->getServiceLocator());
$form = new AddSiteForm($this->getServiceLocator());
$form->setHydrator(new DoctrineObject($entityManager));
$form->bind($site);
$form->get('timezone')->setValue(335);
$form->get('currencyCode')->setValue('GBP');

How to set the default selected value for a Doctrine ObjectRadio element

I've got a simple user registration form where a user can choose their own user type. The user type maps to a role. This is part of a zf2 application using the doctrine2 module.
The relevant part of the init() method of my user fieldset looks like this:
public function init()
{
// ... other field definitions ...
$roleRadio = new ObjectRadio('role');
$roleRadio->setLabel('What type of user are you?')
->setOptions(
array(
'object_manager' => $this->objectManager,
'target_class' => 'MyUser\Entity\Role',
'property' => 'roleId',
'is_method' => true,
'find_method' => array(
'name' => 'findBy',
'params' => array(
'criteria' => array('userselectable' => true),
'orderBy' => array('displayorder' => 'ASC'),
),
),
)
);
$this->add($roleRadio);
// ... more stuff ...
}
I'm using Doctrine's ObjectRadio class for this element to automatically populate the value options. Is there any way to set the default selected value?
I know I can just do something like this:
$form->get('user')->get('role')->setValue(3);
But I don't want to hard code this and I also don't want to put that kind of logic in my controller.
Any suggestions?
I don't know what do you mean by "I don't want to hard code this", but you can do it as you said in your controller, or you can do it in the form definition by setting attributes as the following:
$roleRadio->setAttributes(array('value' => 3));