I am not sure why this grid is showing footer totals on the first row of the grid. Has anyone run into this issue and able to fix it?
This is for the grid total not group totals:
Looks like the <tfoot> element is generated before the <tbody> element.
Grid razor code.
#(Html.Kendo().Grid(Model)
.Name("SalesSummaryGrid")
.Columns(c =>
{
c.Bound(p => p.GroupName).Title("Sales Type").Hidden();
c.Bound(p => p.Title).Title("CATEGORY")
.FooterTemplate(#<text>Total: </text>)
.Width(200);
c.Bound(p => p.Value).Title("GROSS")
.Width(100)
.FooterTemplate(#<text>#item.Sum</text>)
.Format("{0:C2}");
c.Bound(p => p.Comps).Title("COMP")
.Width(100)
.Format("{0:C2}");
c.Bound(p => p.Discounts).Title("DISCOUNTS")
.Width(100)
.Format("{0:C2}");
c.Bound(p => p.Voids).Title("VOIDS")
.Width(100)
.Format("{0:C2}");
c.Bound(p => p.NetSales).Title("NET")
.Width(100)
.Format("{0:C2}");
c.Bound(p => p.NetPercentage).Title("% OF NET")
.Width(100)
.Format("{0:P2}");
})
.Sortable()
.DataSource(dataSource => dataSource
.Server()
.Aggregates(aggregates =>
{
aggregates.Add(p => p.Value).Sum();
})
.Group(groups => groups.Add(p => p.GroupName))
)
)
I tried many different things, and stripped a lot of formatting from this grid. I believe this should work out of the box.
Related
I have the following array at the top of the view file:
$order_status = array(
'nocourier' => 'در حال جستجوی پیک',
'accepted' => 'پیک تعیین شد',
'picking' => 'در حال دریافت مرسوله',
'delivered' => 'تحویل داده شد'
);
And later in the page, I want to use it inside one of the columns of the dataprovider table as below:
[
'label' => 'Status',
'format' => 'raw',
'value' => function ($model, $order_status) {
return Html::a("<div class='col-sm-8 progress' style='padding: 0px; height: 10px;'>
<div class='progress-bar ".$model->status."'></div>
</div><label class='col-sm-4'>".$order_status[$model->status]."</label>", null);
},
'headerOptions' => ['style' => 'text-align: center;'],
'contentOptions' => ['style' => 'width: 300px;']
]
But I get empty label. What am I missing?
could be you need use for pass the content of the array to the anonymous function eg:
'value' => function ($model) use ($order_status){
return Html::a("<div class='col-sm-8 progress' style='padding: 0px; height: 10px;'>
<div class='progress-bar ".$model->status."'></div>
</div><label class='col-sm-4'>".$order_status[$model->status]."</label>", null);
},
i dont know this language but i can se one things that is wrong.
you are creating a function that containe $order_status. so when you call Value you have to pass on $order_status
Value($model , $order_status) for it to work.
i would call $order_status parameter for somthing else too.
I use the kendo ui mvc grid.
I set the columns to Editable(false);
I can still edit those fields in the popup editing dialog. Why?
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.FirstName).Editable(false);
model.Field(p => p.LastName).Editable(false);
}
)
Popups always has to be customized.
In Views > Shared > EditorTemplates > Person (or whatever your class is) you just toss in whatever you want
#model TelerikMvcApp1.Models.Foo.Person
<div>
#Html.HiddenFor(person => person.Id)
<div class="editor-label">
<label for="Title">First Name</label>
</div>
<div class="editor-field">
#Html.Kendo().TextBoxFor(person => person.FirstName)
</div>
</div>
I have a Kendo UI grid with a toolbar (Razor syntax) and I cannot figure out what to pass as an argument into the DestroyButton/EditButton. I know the button expects "dataItem" - but how do I get that?
This is my grid:
#(Html.Kendo().Grid<AspNetPermission>().Name("grid")
.DataSource(ds => ds.Ajax().Read(read => read.Action("Permissions_Read", "AspNetPermissions"))
.Model(model => model.Id(p => p.Id))
.Create(create => create.Action("Create", "AspNetPermissions").Data("sendAntiForgery"))
.Update(update => update.Action("Edit", "AspNetPermissions").Data("sendAntiForgery"))
.Destroy(destroy => destroy.Action("Delete", "AspNetPermissions").Data("sendAntiForgery"))
)
.Columns(columns =>
{
columns.Bound(permission => permission.Name).Width(300);
})
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Single)
.Type(GridSelectionType.Row))
.Sortable()
.Pageable()
.Editable(edit => edit.Enabled(true))
.ToolBar(tb => tb.Template(
#<text>
#*display buttons only if user is enabled*#
#if (ViewBag.CanUserManage == true)
{
#item.CreateButton("Add", new{#class="SPAdd"})
#item.EditButton(whatToPutHere) <!-- This is where I have a problem -->
#item.DestroyButton(whatToPutHere) <!-- This is where I have a problem -->
#item.SaveButton("Save","Cancel",new{#class="SPSave"})
}
</text>
))
.Events(events => events
.DataBinding("onGridDataBinding")
.Change("onGridSelectionChanged")
.DataBound("onGridDataBound")
)
)
}
Thx in Advance,
Frank
Something similar to this:
.ToolBar(b => b.Template(#"<div class='grid-column-right'>
<a class='k-button k-button-icontext k-grid-add' style='margin-right:40px; ' href='javascript: add(0)'>+ Add</a>
<a class='k-button k-button-icontext k-grid-refresh' href='javascript: refreshGridByName(""FilePattern#=uid#"")'>Refresh</a>
</div>"))
My goal is to let ZendForm generate my form in this way:
a DIV wrapper that include the normal DD and DT Zend tag... My DIV need to have the ID tag with the id of the element like this:
<dl>
<div id="65-div">
<dt id="65-label"><label for="65" class="required">Nome</label></dt>
<dd id="65-element">
<input type="text" name="65" id="65" value="">
</dd>
</div>
<div id="66-div">
...... ...
</div>
</dl>
I was able to reach my goal doing that:
$Element = $this->createElement('text', $result->request_field__ID);
$Element->clearDecorators()
->addDecorator('ViewHelper')
->addDecorator('Errors')
->addDecorator(array('data'=>'HtmlTag'), array('tag' => 'dd', 'id' => $Element->getId() . '-div', 'class' => 'zendData'))
->addDecorator(array('labelDivOpen' => 'HtmlTag'), array('tag' => 'dt', 'placement' => 'prepend', 'closeOnly' => true))
->addDecorator('Label')
->addDecorator(array('labelDivClose' => 'HtmlTag'), array('tag' => 'dt', 'id' => $Element->getId() . '-label', 'class'=>'zendLabel','placement' => 'prepend', 'openOnly' => true))
->addDecorator(array('row' => 'HtmlTag'), array('tag' => 'div', 'id' => $Element->getId() . '-div'));
Is this the best way?
Why I'm doing that?
Because I generate my form dinamically... And I want to hide some fields and then display it with Jquery if some conditions happend...
In order to hide my field I use:
$Element->getDecorator('row')->setOptions(array('style' => 'display:none;'));
Is this also the best way?
This doesn't look like valid HTML to me. You'd be much better off dropping the divs and using the IDs on the dt and dd that are already there, so just display none those when you want to hide an element. Also, IDs cannot start with a number, so you might want to reverse your naming scheme so that it's element-65 instead.
I would rather not deal with decorators as my form design is not exactly straight forward, but i would like to keep the functionality of validating the forms.
So i have it set up where sub forms are working correctly, but when i try to style it manually in my viewscript i get the name without the parent. I've seen other posts that are similar, but i haven't found a solution.
Example:
This is in my view script
<?php echo $this->form->username->renderViewHelper();?>
I then get
<input type="text" value="" id="username" name="username">
When rendered. It should be
<input type="text" value="" id="form1-username" name="form1[username]">
How do i get that form1 portion?
Thanks!
Edit
Ok, so i found one way.
By using belongTo, it works:
$form1->addElements(array(
new Zend_Form_Element_Text('username', array(
'belongsTo' => 'form1',
'required' => true,
'label' => 'Username:',
'filters' => array('StringTrim', 'StringToLower'),
'validators' => array(
'Alnum',
array('Regex',
false,
array('/^[a-z][a-z0-9]{2,}$/'))
)
))
));
Is there a better way to do this or is this the only way?
Edit2
public function prepareSubForm($spec){
if (is_string($spec)) {
$subForm = $this->{$spec};
} elseif ($spec instanceof Zend_Form_SubForm) {
$subForm = $spec;
} else {
throw new Exception('Invalid argument passed to ' .
__FUNCTION__ . '()');
}
$this->setSubFormDecorators($subForm)
->addSubmitButton($subForm)
->addSubFormActions($subForm);
return $subForm;
}
public function setSubFormDecorators(Zend_Form_SubForm $subForm){
$subForm->setDecorators(array(
'FormElements', \\<--- I tried to change this to PrepareElements before.
array('HtmlTag', array('tag' => 'dl',
'class' => 'zend_form')),
'Form',
));
return $this;
}
I believe you can get your desired output just by using:
<?php echo $this->form->username; ?>
I get the expected output when calling this without renderViewHelper. This is also without any special code for decorators or preparing sub forms. All I had to do was add belongsTo to the form element.
UPDATED:
If you set this to be your default decorator, you can eliminate the dd/dt tags from rendering, instead it will use a div. Then you may be closer to getting the custom output you want. You can change the tag in HtmlTag from div to whatever tag you would like to wrap your elements in. This is what I use mostly:
array(
'ViewHelper',
'Errors',
array('Description', array('tag' => 'p', 'class' => 'description')),
array('HtmlTag', array('tag' => 'div', 'class' => 'form-div')),
array('Label', array('class' => 'form-label', 'requiredSuffix' => '*'))
);
This is the default for Zend Framework:
array(
'ViewHelper',
'Errors',
array('Description', array('tag' => 'p', 'class' => 'description')),
array('HtmlTag', array('tag' => 'dd', 'id' => array('callback' => $getId)))
array('Label', array('tag' => 'dt'))
);
Note that file, and submit/button elements use different decorators.
Also see this answer