Answer How to render the edit template in Kendo ListView - kendo-asp.net-mvc

Answering the following question Kendo MVC ListView Editing

Kendo in MVC uses a folder with the following path View/Shared/EditorTemplates
inside this folder you must insert all the templates you call by name, example:
#(Html.Kendo().ListView<temp.Models.YourTable>(Model)
.Name("LisView")
.TagName("div")
.ClientTemplateId("templateView") => here goes the template for data
.DataSource(dataSource => dataSource
.Model(m => m.Id("ID"))
.ServerOperation(false)
.Read(read => read.Action("ActionRead", "Controller"))
)
.Editable(edit => edit.TemplateName("EditTmpl"))
)
EditTmpl => // this template is the one that you must store in the folder that I refer above.
hope this helps.

Related

Livewire: How to update or re-render when use wire:ignore in <select>

Component parent:
Component child: admin.category.select-recursive
-- Problem: I use recursive for list categories in , I use Modal bootstrap, I use wire:ignore.self for component parent, and use wire.ignore for , everything showing Ok. I add new data into database from component parent success. But when I re-open modal component parent, I can't see the data just added in . I want re-render or update data just added in . Thanhks you reading. Have a nice day !!!
I had fix success problem.
I add key(time() . rand(0, 999)) in #livewire(...) from component parent
before:
#livewire('admin.category.select-recursive',['categories' => $categories,'parent_id' => 0,'icon' => '',])
after:
#livewire('admin.category.select-recursive',['categories' => $categories,'parent_id' => 0,'icon' => '',],key(time() . rand(0, 999)))
Thanhks every one :D

How to set regular expression parameter constraints for Route::group in Laravel 4?

For simple routes I know I can user where statement. But what about parameters in Route::group() prefix
<?php
Route::get('user/{id}', 'UserController#profile')->where('id', '[0-9]+');
Route::group(['prefix' => 'foo/{bar}'], function() {
// ...
})->where('bar', '[0-9a-Z]+'); // this won't work
I'm using laravel 5.5. I had same problem and find this question in search.
I've tried to use the solution defined by #lukasgeiter and faced a problem:
The value of
$group->getRoutes()
was not only the routes of current group.
But I fixed my problem by specifying condition in route group definition.
Route::group([
'prefix' => 'foo/{bar}',
'where' => ['bar' => '[0-9a-Z]+']
],
function() {
// ...
});
And it worked for me :)
Out of the box the laravel router doesn't support this. You can use the Enhanced Router package from Jason Lewis or a fork that enables support for Laravel 4.2
Alternatively you can do it yourself. You could basically add the where condition to every route inside the group:
Route::group(['prefix' => 'foo/{bar}'], function() {
Route::get('/', function(){
// ...
})->where('bar', '[0-9a-Z]+');
});
Or do it a bit more dynamic and add this at the bottom of your route group:
Route::group(['prefix' => 'foo/{bar}'], function($group) {
// ...
foreach($group->getRoutes() as $route){
$route->where('bar', '[0-9a-Z]+');
}
});
One of possible not perfect solution in my view will be
// Route Model Binding
Route::model('user', 'User');
// Route Constraint Pattern
Route::pattern('user', '[0-9]+');
// Route Definition
Route::get('anything/{user}', 'UserController#anyFunction');
.
.
Route::resource('user', 'UsersController');

Displaying a custom twig template with Sonata and Symfony2

For my need, I'm planning to add a custom column to a entity list.
I've written this inside the configureListFields :
->add('_action', 'actions', array(
'actions' => array(
'code' => array('template' => 'BOBAdminBundle:test:custom.html.twig'),
)
))
My twig :
<img src="{{ asset('bundles/sonataadmin/famfamfam/delete.png') }}" />
It works.
Problem : I don't know why :S, since I've just copy/paste the code from somewhere.
I figured out than the '_action' determined the name of the column. But what if I want to change it ?
Where does this 'actions' name come from ? Where can I change it ?
The _action is used to add custom actions for the list items. Like edit and delete which are set by default. Here is a full documentation:
List actions
You can set actions for the list items by adding an ‘_action’ field in configureListFields:
<?php
$listMapper->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'edit' => array(),
)
))
Edit and delete actions are enabled in the default configuration. You can add your own! Default template file is: *SonataAdminBundle:CRUD:list_action[ACTION_NAME].html.twig*
You can specify your own by setting up the ‘template’ option like so:
<?php
$listMapper->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'edit' => array(),
'delete' => array('template' => 'MyBundle:MyController:my_partial.html.twig'),
)
))

Custom Prestashop Admin Module

I am developing a module for prestashop (basically, it's a very custom import of data and the only thing I need is to have a form and process data). I have created controller class derived from the ModuleAdminController but the problem is where should I put the tpl file containing the look of my custom form?
I realize that I can put tpl file to the templates but I want to keep all files within my module folder, is it possible (probably somewhere like "/views/templates/admin")?
This is the most easy method to create a basic admin controller / action in Prestashop 1.6
Create basic configuration :
./config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>foo</name>
<displayName><![CDATA[Foo]]></displayName>
<version><![CDATA[2.1.3]]></version>
<description><![CDATA[Bar.]]></description>
<author><![CDATA[your-name]]></author>
<tab><![CDATA[administration]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>
./foo.php
if (!defined('_PS_VERSION_'))
exit;
class BarcodeEasyPrint extends Module
{
public function __construct()
{
$this->name = 'foo';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'your-name-here';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Foo');
$this->description = $this->l('Bar.');
if ((int)Tools::getValue('p'))
$this->page = (int)Tools::getValue('p');
}
}
You need to create the controller with base functions :
./controllers/admin/AdminFooController.php
class AdminFooController extends ModuleAdminController {
public function __construct() {
$this->bootstrap = true;
parent::__construct();
}
public function createTemplate($tpl_name) {
if (file_exists($this->getTemplatePath() . $tpl_name) && $this->viewAccess())
return $this->context->smarty->createTemplate($this- >getTemplatePath() . $tpl_name, $this->context->smarty);
return parent::createTemplate($tpl_name);
}
public function initContent(){
parent::initContent();
$tpl = $this->createTemplate('content.tpl')->fetch();
/* DO STUFF HERE */
$posts = array();
$this->context->smarty->assign('posts', $posts);
}
}
You can use boostrap directly in the template file :
./views/templates/admin/content.tpl
<div class="row">
<div class="col-md-6">
</div>
<div class="col-md-6">
</div>
</div>
If it is an admin module only, then you will have no need to create any views. Because Prestashop provides a nice structure for admin section which is easy to use and we dont need to use any views or .tpl files. For admin section, normally three types of views or .tpl files are required, one for data display in grid, second for form and third for displaying a single record.
Prestashop already created .tpl files for them which you can find in "admin_folder/themes/default/templates". In our controllers for admin, for form and for data grid, we just create arrays and PS handles to view the form and data grid according to the arrays we created.
So if you need a custom form at admin, then create a public function renderForm and create the form array in it, like below:
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Video'),
'image' => '../img/admin/tab-genders.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Video Title:'),
'name' => 'title',
'lang' => true,
'size' => 70,
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()##"�{}_$%:',
'required' => true
),
array(
'type' => 'textarea',
'label' => $this->l('Video Code'),
'name' => 'video_code',
'rows' => 5,
'cols' => 70,
'desc' => $this->l('Place the embed code for the video')
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
return parent::renderForm();
} /* End of render member */
For other fields, checkout other prestashop admin controllers and you will see that how easily we can create forms in PS using that simple definitions in the arrays and we dont need to create .tpl files.
For front end, we can use the new modules MVC structure, where our module folder have sub folders for controllers (controllers/front, controllers/admin) , views and models .
Hope this will help you.
Thank you
You need to use the helper form, here is the documentation for it, it is really easy to use ;) .
http://doc.prestashop.com/display/PS15/HelperForm
You also can find more information about how and where to use helper form, look for the function getContent() and displayForm().
http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module
unfortunately any document not exist to point directly to solve this question but hear i have some URLs really useful and you should combine theme and get your realize:
http://presthemes.com/prestashop-news/modules-classes-and-controller-override-by-julien-breux-4.html
http://doc.prestashop.com/display/PS15/Diving+into+PrestaShop+Core+development
http://doc.prestashop.com/display/PS15/New+Developers+Features+In+PrestaShop+1.5
http://blog.belvg.com/how-to-implement-a-controller.html
best regards
extending the answer from #altafhussain create a folder views/templates/admin in your module and place your customview.tpl
Than append the free text block as below.
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Legend')
),
'input' => array(
array(
'type' => 'free',
'label' => 'Whatever label text',
'desc' => $this->display(__FILE__,'views/templates/admin/customview.tpl'),
'name' => 'FREE_TEXT',
'required' => false
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
return parent::renderForm();
}

Lithium: load view from library

I am working on a 3rd party library in PROJECTROOT/libraries/mylib. have a controller in mylib/controllers, which is working. li3 tells me it expects a view in PROJECTROOT/app/views/ -- how can I load a view from mylib/views instead of app ?
That can be easily achieved by setting the render paths in a controller. You probably want to do that for every controller in mylib, so a BaseController that all controllers extent from is a good idea. You can then use lithiums default called method _init() to setup the configurtion like that:
class BaseController extends \lithium\action\Controller {
public function _init() {
parent::_init();
$this->_render['paths'] = array(
'template' => array(
LITHIUM_APP_PATH . '/views/{:controller}/{:template}.{:type}.php',
'{:library}/views/{:controller}/{:template}.{:type}.php',
),
'layout' => array(
LITHIUM_APP_PATH . '/views/layouts/{:layout}.{:type}.php',
'{:library}/views/layouts/{:layout}.{:type}.php',
),
'element' => array(
LITHIUM_APP_PATH . '/views/elements/{:template}.{:type}.php',
'{:library}/views/elements/{:template}.{:type}.php',
),
);
}
You can have a look at it here: https://github.com/bruensicke/radium/blob/master/controllers/BaseController.php
Please note, that i set it up that way, so the application can overwrite specific views in order to customize it further.
Also, there is an issue/pull-request on github regarding that topic, have a look here:
https://github.com/UnionOfRAD/lithium/pull/650