Get KoolPHP UI with 30% OFF!

How do you make a password column? / Or how do you make custom column templates for inserts?

Alexander
I am trying to create a table to manage users with columns for the username, password etc.
The problem is that I can't find a simple solution how to mask the text of the password column or just make an input element with "type=password" instead of "type=text" like the ones koolgrid normally creates.
So far I came uple with the following solution, using a customColumn and the following templates.
 $column->ItemTemplate = '<div class="passwordColumn">{password}</div>';
 $column->EditItemTemplate = '<div class="passwordColumn"> <input id="pw_input" class="kgrEnNoPo" name="password" type="password" value={password} style="width:100%"/> </div>';
 

This works fine for displaying and editing existing data, but the EditItemTemplate is not displayed for inserts. So there is currently no way to define a password when inserting a new user.
So is there a simple way to just make a normal databoundcolumn with "type=password" or to somehow define an insert template for a column?
I guess it would be possible to solve this issue by making an template for the whole insert form, but this seems like too much trouble for me, for what I want to achieve.
Posted Nov 30, 2016 Kool
Abraham
If you own kool php then you have the src then you can do an extenssion of the class GridBoundColumn then:
myPasswordColumn.php:
<?php
class myPasswordColumn extends GridBoundColumn
{
	var $aa;
	function Render($_row)
	{
		$item = str_replace("{disabled}","disabled",$this->InlineEditRender($_row));
		return $item;
	}
    function InlineEditRender($_row) {
		$text = $_row->DataItem[$this->DataField];
		$item = 
				"
				<input id='{id}' name='{id}' align='{align}' type='password' style='background-color:{color};margin:0;width:100%;height:100%' value='{text}' {disabled}/>
				";						
		$item = str_replace("{text}",$text,$item);
		$item = _replace("{id}", $_row->_UniqueID . "_" . $this->_UniqueID."_input", $item);	
			
		return $item;
    }
    function FormEditRender($_row) {
		return $this->InlineEditRender($_row);
    }
	
	function RenderExport($_row){
		return "*****";
	}
	
	function CreateInstance($_instance = null)
	{
		if($_instance===null)
		{
			$_instance = new myPasswordColumn ();		
		}
		parent::CreateInstance($_instance);
		$_instance->aa = $this->aa;
		return $_instance;
	}
}	
?>

Remember to requiere this file just after requiering the koolgrid!!!!!
Posted Jan 31, 2017 , edited Jan 31, 2017 Kool
Alexander
Thanks that works perfectly for my needs and this issue has been bugging me far too long! That's also a better solution than hacking something together with a custom input form or using my work around.
Posted Feb 9, 2017 Kool