insert data manually or searching
- Single Page
Posted 17 April 2012 - 13:19 PM
I already make a application by grocery crud.
Now I starting another application. But I faces a problem.
I attach a file.
Here see a input field name of source which is get by set_relation function.
Now I need.
1. If not match the searching data, i want to type new source data and then insert.
2. If match and need to extend some words(if need) and then insert.
3. if match and no need to exatend and then insert.
Help please.
Posted 17 April 2012 - 23:01 PM
You have to change the core library and add this to your project. If you do it, it will be really useful if you share your code here so you can also help other people with a similar problem.
Posted 20 June 2012 - 21:20 PM
- If a job title [b]is[/b] in the list, select and use it.
- If a job title [b]is not[/b] in the list, use it and update the database
- If a job title needs to be updated (misspelling or other reason), select it from the list, make the edit(s), and save to update that record in the database.
I think the last part would be the hardest, especially with foreign keys. Maybe there could be an option to either add as a new record, or update existing?
Still getting used to grocery CRUD, but really like it so far... it's made the admin process a ton easier (thanks!). If I'm able to get anything like that working, I'll be more than happy to share. I haven't seen it elsewhere, but then again - I haven't looked for it too much yet.
// dropcase
Posted 20 June 2012 - 22:04 PM
I hope I was clear
Posted 21 June 2012 - 19:32 PM
Still trying to figure out how to make it easy enough for most users... and still make it manageable from the backend. Good point on the IDs too, I'll have to wrap my head around that before I get much further. In your example, you'd have to add the new value to the second table, then write the new ID back to the first table. Possible, but maybe a lot of callback_before_update (or insert for adds) work.
Back to the IDE...
// dropcase
Posted 22 June 2012 - 12:38 PM
If you want to keep this as separate tables, then it's best you enforce the values on the combox. If the value is not there, then you allow the user to open the grid that will eventually populate the combo and register beforehand.
Posted 04 November 2012 - 08:46 AM
I solved this problem but i don't know is it appropriate?
//My controller function:
function inventory_add()
{
// Add some js and css file for search
$this->grocery_crud->set_css('css_autocomplete/jquery-ui.css');
$this->grocery_crud->set_js('js_autocomplete/jquery-1.8.2.js');
$this->grocery_crud->set_js('js_autocomplete/jquery-ui.js');
$this->grocery_crud->set_js('js/function_search.js');
$this->grocery_crud->set_table('pos_inventory');
$this->grocery_crud->set_subject('Inventory Setup');
$this->grocery_crud->callback_add_field('author',array($this,'add_field_callback_1')); //field which need search
-----------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
}
function add_field_callback_1()
{
return '<input id="tags" name="author" style="width:505px; height:25px;" />';
}
// function_search.js code
window.onload = function () {
var alldata_test= new Array;
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
}catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
var host = getBaseURL();
url_tags = host+"index.php/inventory/tags_ajaxsearch[/color]/";
var queryString='';
ajaxRequest.open("POST",url_tags, true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxRequest.send(queryString);
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var resp = ajaxRequest.responseText;
alldata_test = resp.split("xxx");
alert(alldata_test);
$( "#tags" ).autocomplete({
source: alldata_test
});
}
}
}
//tags_ajaxsearch function
function tags_ajaxsearch[/color]()
{
$this->db->select('author');
$this->db->from('pos_inventory');
$query = $this->db->get();
$data1 = array();
foreach ($query->result() as $row)
{
$data1[] = $row->author;
}
$author = implode('xxx', $data1);
echo $author;
}
The Output : [attachment=337:search.png]
Any easy idea?