Help adding combo to grid

Hi Guys

Could someone please show me how to add a combo box to a grid column when using attachGrid() to a layout and Connector ? I have checked the documentation but I can’t figure it out.

[code]contactsGrid = layout.cells(“a”).attachGrid();
contactsGrid.setHeader(“Domain,Path,Category”);
contactsGrid.setInitWidths(“250,250,250”);
contactsGrid.setColAlign(“left,left,left”);

  contactsGrid.setColSorting("str,str,str");
  contactsGrid.attachHeader("#text_filter,#text_filter,#text_filter");
  contactsGrid.enableSmartRendering(true);
  contactsGrid.init();
  contactsGrid.load("/cnpro/index.php/contacts/get_urls")[/code]

Is how I’m creating the grid.

I then pull in data via get_urls (this is using CodeIgniter and phpci):

[code] public function get_urls()
{
$this->load->database();
$this->load->model(“url_model”);
$connector = new GridConnector($this->db, “phpCI”);
$connector->configure(“tblurl_custom”, “id”, “domain, path, category”);
$connector->useModel($this->url_model);
$connector->render();

}[/code]

This works fine if I just want to edit cells as text input boxes. I want to make the 3rd column a drop down when double clicked, which uses a list of values also obtained from the database. How do I go about this ? It does not seem to be covered clearly in the examples.

I had a look at Excell’s but it still doesn’t make sense to me.

Any help appreciated

Thanks
Tim

Please, try to use co/coro exCell type:
docs.dhtmlx.com/doku.php?id=dhtm … n_from_xml
or a “combo” exCell:
docs.dhtmlx.com/doku.php?id=dhtm … cell_combo

Thank you… I could not find the first link when searching the docs. I will try with this approach, it looks like it should work for me. If I can get a proof of concept working I will be able to purchase the Pro version :slight_smile:

I’m still not having much luck, I don’t suppose you could post a basic example ?

What I observe is, if I add a column as combo, e.g.

contactsGrid.setColTypes("ed,ed,co"); combo = contactsGrid.getCombo(2); // 3rd column combo.put("hello", "world");

The GET request made by the grid appends ?connector=true&dhx_colls=2

Then I get a 500 Internal Server Error:

This query must be happening inside the connector but I have told the phpCI to use my own model e.g.:

$this->load->database(); $this->load->model("url_model"); $connector = new GridConnector($this->db, "phpCI"); $connector->configure("tblurl_custom", "id", "domain, path, category"); $connector->useModel($this->url_model); $connector->render();

However this does not appear to be used. Confused!

Ah, I fixed it by adding the table that contains the ‘category’ field to the “configure” parameter, e.g.

$connector->configure("tblurl_custom, tblurl_custom_categories", "id", "domain, path, category");

Is there a document on “configure” ?

Thanks

Sorry, one more question…

Using the method above, how can I set the option ID and value ? Right now the query returns the category name only. How do I tell the treegrid to use one field as ID and another field as value ?

My query would be changed as follows:

select tblurl_custom.id as id , tblurl_custom_categories.id as category_id, tblurl_custom_categories.category as category, tblurl_custom.domain as domain, tblurl_custom.path as path FROM tblurl_custom, tblurl_custom_categories WHERE tblurl_custom.category_id = tblurl_custom_categories.id AND tblurl_custom_categories.is_bypass = 0

So in the grid column 1 = domain, column 2 = path, column 3 = category but within the 3rd column combo it should use:

<option value="CATEGORY_ID">CATEGORY</option>

rather than

<option>CATEGORY</option>

This will make it easier for updating the database once the combo box has changed.

Thanks