We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Pass Parameter to do a search.

We have a grid, with data populating perfectly as required, Using our own objects. example. Document

public int Id{get;set}

public string DocumentName{get;set;}

public string DocumentEncryptionCode{get;set;}

public Int64 DocumentSize{get;set;}

...........


To retrieve the objects we would say:

List<DocumentObject> searchObjects = Document.SearchDocumentObjects(applicationObject.Id, "")

Returning n documents

After this loads the end user decides we need all documents with an '@' (could be any string) in the users who have downloaded the document.

This is not stored in table or displayed,

so we have a stored procedure, object retrieval doing the following:

List<DocumentObject> searchObjects = Document.SearchDocumentObjectsWithBorrowerName(applicationObject.Id, "@")

how do I call the

     [AcceptVerbs(HttpVerbs.Post)]
public ActionResult DocumentSearch(PagingParams args){ /*we want to include a parameter like string searchString*/
        ApplicationObject applicationObject = Application.GetApplicationByName("SampleDocuments");
        List<DocumentSearchObject> searchObjects = DocumentSearch.SearchDocumentObjectsWithBorrowerName(applicationObject.Id, searchString);
       return searchObjects.GridJSONActions<SearchDocumentObject>();

}

What I need to do is pass certain parameters to a Controller,

Our view has the following:

 @{ Html.Syncfusion().Grid<DocumentSearchObject>("OutputGrid")
 .Caption("Gas Victoria")
 .AutoFormat(Skins.Metro)
 .ActionMode(ActionMode.JSON)
 .EnablePaging()
 .Column(columns =>
 {
   columns.Add(p => p.DocumentRevisionId).HeaderText("Title").TemplateColumn(true).TemplateName("../Templates/PLINEThumbnail").Width(200);
   columns.Add(p => p.Desciption).HeaderText("Desciption").Width(150);
   columns.Add(p => p.Filename).HeaderText("FileName").Width(100);
   columns.Add(p => p.DateStamp).Width(55).Format("{0:dd/MM/yyyy}");})
 .Scrolling(scroll => scroll.Height(560))
.PageSettings(p =>
{p.PageCount(15);p.PageSize(24);p.AllowPaging(true);})
.Render();
}


 


2 Replies

DA Darren March 31, 2014 02:21 AM UTC

Ok I worked this part out, I have to call the

.QueryParam("?descriptionText=" + "&titleText=" + "&startDateTime=" + "&EndDateTime=")

but now my issue is how do I fill in the values. I have a fields that someone enters the data into: eg descriptionTextBox,

 

how do I get this out of the form and into the query string????? Ive tried everything. I cant pass the formCollection through as this only passes the DataGridValues

 



SK Shanmugaraja K Syncfusion Team April 2, 2014 11:56 AM UTC

Hi Darren,

 

Thanks for using Syncfusion products.

 

We would like to let you know that your requirement has been achieved by handling queryparam property to pass the text value to controller. Please refer the below code snippet to achieve your requirement.

 

[CSHTML]

 

@{ using (Html.BeginForm("ControlsInLayout", "Layout", FormMethod.Get))

 {

    <p>Enter duration: </p>

    @Html.TextBox("duration")

    <input type="submit" value="submit" id="sub"/>

 }}

….

 

<div class="sample-panel-margin" id="grid1" style="width: 95%;">

        @(Html.Syncfusion().Grid<qureyparam.Models.Student>("GenericListGrid")

    .ActionMode(ActionMode.JSON)

    .Caption("Student Details")

….

.QueryParam("?duration=" +ViewData["Detail"])

 

[CS]

 

public ActionResult ControlsInLayout(int? duration)

        {

            ViewData["Detail"] = duration;

            return View();

        }

      [AcceptVerbs(HttpVerbs.Post)]

      public ActionResult ControlsInLayout(PagingParams args, int? duration)

      {

          IEnumerable data;

          if (duration != null)

          {

              data = new StudentDataContext().Student.Where(s => s.Duration == duration).Take(10).ToList();

          }

          else

          {

              data = new StudentDataContext().Student.Take(100).ToList();

          }

          return data.GridJSONActions<Student>();

      }

 

Also refer the below sample for further reference


 

If we misunderstood your requirement  please get back to us with more information so that we can analyse based on your scenario and provide you a better solution.

 

Please let us know if you need further assistance.

 

Regards,

Shanmugaraja K


Attachment: qureyparam_2b765f4c.zip

Loader.
Live Chat Icon For mobile
Up arrow icon