StudioCherno / Walnut

Walnut is a simple application framework for Vulkan and Dear ImGui apps
MIT License
2.11k stars 392 forks source link

Filter in a Table #58

Open MarcuzziGiuseppe opened 1 year ago

MarcuzziGiuseppe commented 1 year ago

Hi, I would like to be able to filter in a table but I can't understand how to connect the 2 things. This is my table and I would not like to change it if possible:

Thanks to any help.

int selectedRow = -1; static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable; if (ImGui::BeginTable("table1", 3, flags)) { ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("MARCA", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("DESCRIZIONE", ImGuiTableColumnFlags_WidthStretch); ImGui::TableHeadersRow(); for (int i = 0; i < pompeDisponibili.size(); i++) { string testo = std::to_string(pompeDisponibili.at(i)->getId()); ImGui::TableNextRow(); ImGui::TableNextColumn(); if (ImGui::Selectable(testo.c_str(), selectedRow == i, ImGuiSelectableFlags_SpanAllColumns)) { selectedRow = i; } testo = pompeDisponibili.at(i)->getMarca(); ImGui::TableNextColumn(); ImGui::Text(testo.c_str()); ImGui::TableNextColumn(); testo = pompeDisponibili.at(i)->getDescription(); ImGui::Text(testo.c_str()); } } ImGui::EndTable();