1
I have a table in HTML
and in a table column there is a link that opens a Modal. In this modal I register approvals and show who approved and the date of approval (More than one person can approve, so have a list of approvals). To register I need Idsolicitação and Idempresa and to list only need Idsolicitação. And I am in this situation:
Table Column:
`<td class="cell-action" data-idsolicitacao="@(solicitacao.IdSolicitacao)" data-toggle="modal" data-target="#SolicitacoesModal" style="cursor:pointer"><a onclick="$('#IdSolicitacao').val(@solicitacao.IdSolicitacao);$('#IdEmpresa').val(@solicitacao.IdEmpresa);">Histórico</a></td>`
Modal:
<div class="modal-content">
<div class="modal-body">
@using (Html.BeginForm("CreateSolicitacao", "Solicitacoes", FormMethod.Post))
{
<input hidden="hidden" id="IdSolicitacao" name="IdSolicitacao"/>
<input hidden="hidden" id="IdEmpresa" name="IdEmpresa" />
<div class="content-header col-md-8 controls">
<h4 class="modal-title" id="aprovacoes">APROVAÇÕES</h4>
</div>
<div class="content-header col-md-4 controls">
<h4 class="modal-title" id="historico">HISTÓRICO</h4>
<div id="conteudoHistorico"></div>
<script type="text/javascript">
var item = "";
$.ajax({
type: 'POST',
url: "@Url.Action("_ListaHistorico", "Solicitacoes")",
data: { IdSolicitacao: id },
dataType: 'JSON',
success: function (result) {
for (var i = 0; i <= result.length; i++) {
var item = result[i];
$("#conteudoHistorico").append(
" <div>DataCadastro: " + item.DataCadastro + "</div>" +
" <div>Nome: " + item.UsuarioNome + "</div>" +
" <div>Observacao: " + item.Observacao + "</div>"
);
}
},
error: function (result) {
alert("ERRO!");
}
});
</script>
</div>
<div id="conteudoAprovacoes" class="col-md-8 controls">
@Html.RadioButton("Situacao", true, true)
@Html.Label("Aprovar")
@Html.RadioButton("Situacao", false)
@Html.Label("Reprovar")
<br />
<br />
@Html.SolyosTextArea("Observacao", "col-md-12 controls", "Digite o motivo, ou alguma observação")
<br />
<br />
<br />
<br />
<div class="form-edit-footer" style="padding-right: 15px;">
<input type="submit" value="SALVAR" onclick=""/>
<input type="button" data-dismiss="modal" value="Cancelar" onclick="Solyos_Modal_Form_Close();" />
</div>
</div>
}
</div>
No onclick of td
I can set Idsolicitacao and Idempresa in inputs
Hidden to register, but I can’t access the Idrequest to play on the Ajax date.
How can I do it?
EDIT
I solved the problem as follows:
I added a function calling my onclick Ajax
<td class="cell-action" data-idsolicitacao="@(solicitacao.IdSolicitacao)" data-toggle="modal" data-target="#SolicitacoesModal" style="cursor:pointer"><a onclick="$('#IdSolicitacao').val(@solicitacao.IdSolicitacao);$('#IdEmpresa').val(@solicitacao.IdEmpresa); GetHistorico()">Histórico</a></td>
And in the script:
<script type="text/javascript">
function GetHistorico() {
var item = "";
$.ajax({
type: 'POST',
url: "@Url.Action("_ListaHistorico", "Solicitacoes")",
data: { IdSolicitacao: $('#IdSolicitacao').val() },
dataType: 'JSON',
success: function (result) {
for (var i = 0; i <= result.length; i++) {
var item = result[i];
$("#conteudoHistorico").append(
" <div>DataCadastro: " + item.DataCadastro + "</div>" +
" <div>Nome: " + item.UsuarioNome + "</div>" +
" <div>Observacao: " + item.Observacao + "</div>"
);
}
},
error: function (result) {
alert("ERRO!");
}
});
}
</script>
I managed to solve the problem!
– Thiago Alex